SSH – Import / Export large database

The problem that most of the people get when try to import massive .sql backup is that phpMyAdmin has import file size limit which depends on the hosting company.

How to deal with such issue?
If your hosting provider gives you SSH access, then it’s fairly easy task to accomplish.

Importing large SQL file via SSH

  1. Make sure you have actual uncompressed .sql file uploaded to your server via FTP
  2. Connect to SSH
  3. Navigate to the directory where you .sql file sits (used cd command to navigate)
  4. Run following command

mysql -p -u username database_name < file.sql

Incase your hosting provider doesn’t give SSH access, then you only option is to contact them and request to perform commands above.

P.S. If you have massive .sql and hosting that does not provide SSH access, you probably should consider migrating to better provider. I personally use WebFaction

Export large SQL file via SSH

  1. Connect to SSH
  2. Execute following command

mysqldump -p -u username database_name > dbname.sql

Once executed login to FTP and download your .sql file.