How to import a database over SSH in Hostinger

Import a database over SSH in Hostinger for files over 256 MB: upload the file, connect via SSH, run the mariadb command, and update your config.

Updated 2 days ago

Import a database over SSH in Hostinger when the file is larger than the 256 MB phpMyAdmin import limit, or when a phpMyAdmin import fails. Upload the database file to public_html, connect via SSH, run the mariadb import command, and update your website’s configuration file.

Step 1 – Preparations

Step 2 – Connect via SSH

Step 3 – Import the database

If the database is in compressed format (.sql.gz) use the following command to extract it so it’s in .sql format:

gzip -d database_name.sql.gz

Make sure to replace database_name with your database’s actual name.

To import the database, use this command:

mariadb -u database_username -p database_name < file.sql

If the parameters of your database are:

  • MySQL Database name: u123456789_database

  • MySQL Username: u123456789_admin

  • Uploaded database file: database.sql

The command will look like this:

mariadb -u u123456789_admin -p u123456789_database < database.sql

After that, you will need to enter the database password – the importing process will start immediately. When it is completed, a new line will appear:

-bash-4.2$

Keep in mind that the import will take some time, depending on the size of your database.

If you are on an Agency Hosting plan, the command format is slightly different — the password must be passed inline using the -p flag (no space between the flag and the password), wrapped in single quotes:

mysql -u database_username -p'database_password' database_name < file.sql

Using the same example parameters as above, the command would look like this:

mysql -u u123456789_admin -p'YourPassword123' u123456789_database < database.sql

Note that after running this command, you will not be prompted to enter your password separately — the import process will begin immediately.

Step 4 – Update the configuration file

If the database is required for your website to work properly, you will need to update the connection details in your website’s configuration file.

The specific steps will vary depending on the type of content management system (CMS) you are using. However, in general, you will need to open the configuration file and update the database name, username, password, and host using the details of the new database.

Your database is now imported over SSH and ready for your website to use. For database files under 256 MB, you can also import a database with phpMyAdmin.