All Collections
How to Import a Database Over SSH on cPanel
How to Import a Database Over SSH on cPanel

Importing a database via SSH using cPanel

Updated over a week ago

phpMyAdmin allows you to import databases up to 128 MB; sometimes a little less, when the database has a large number of rows. If importing with phpMyAdmin failed, you can import your database using SSH by following these steps:

Step 1 - Preparation

Step 2 - Connecting via SSH

  • Connect to your hosting via SSH

  • Use the ls command to ensure you are in the root directory, that is, public_html. If you are located in a different directory, use the ls and cd commands to reach it. For example, the process will be similar to this, replacing domain.tld with your domain name:

cd domains
cd domain.tld
cd public_html
  • If the database backup is displayed, go to the next step.

  • If you the backup file is missing, use the File Manager to verify the file is correctly stored in the public_html folder

Step 3 - Import the Database

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

  • MySQL Username: user_admin

  • Uploaded database file: database.sql

The command will look like this:

mysql -u user_admin -p user_database < database.sql

After that you will need to enter the database password - the importing process will start immediately. The import will take some time depending on the size of your database.

When it is completed, a new line will appear:


This line means that the importing process is done, you will see your database tables in phpMyAdmin.

Did this answer your question?