Skip to main content
How to Import a Database Over SSH

Importing a database via SSH at Hostinger

Updated over 6 months ago

phpMyAdmin allows you to import databases up to 256 MB, sometimes slightly less if the database has a large number of rows. If importing your database with phpMyAdmin failed, you can use SSH instead by following these steps:

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.gz.sql

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

To import the database, use this command:

mysql -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:

mysql -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.

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.

Did this answer your question?