How do I import a .sql file using SSH (command line)? Print

  • 0

For large databases, importing over SSH is faster and more reliable than phpMyAdmin.

Before you start

  • Set up SSH access. See How to connect to your hosting with SSH.
  • Upload your .sql file (or .sql.gz) to your hosting, e.g. with FTP.
  • Have your database name, username, password and hostname ready from the MySQL Databases section of your control panel.

Import the file

Connect via SSH, go to the folder with your file, and run:

mysql -h DB_HOSTNAME -u DB_USERNAME -p DB_NAME < backup.sql

Enter the database password when asked. For a compressed file use:

gunzip < backup.sql.gz | mysql -h DB_HOSTNAME -u DB_USERNAME -p DB_NAME

Replace the capital-letter values with your own details. No message means the import worked. Delete the .sql file afterwards so it isn't left on your server.

Need help?

Open a support ticket from your FariHost Client Area or message us on WhatsApp and our team will help you.


Was this answer helpful?

« Back