Import big database file with SSH

Import big database file with SSH

364

phpMyAdmin allows you to import databases up to 256 MB (sometimes a little less, if the database has a lot of rows). If importing with phpMyAdmin failed, you can import your database using SSH. Here are the steps:

Step 1 - Preparation

  • Upload the database (file in .sql format ) to public_html (you can do it via FTP or with File Manager)
  • Create a new database or clear the one you plan to import into
  • If you are not confident in the exact value of your database password - change it

Step 2 - Connecting

  • Connect to your hosting account via SSH
  • Open your root directory (public_html)
  • If the database backup is displayed - great, go to the next step
  • If you do not see the backup file, double-check with the File Manager if the file is indeed uploaded and placed to the public_html.

Step 3 - Import

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.

That’s it! Now you know how to import your MySQL database

- Last updated 1 year ago

Be the first to leave a comment.

You must login to leave a comment