Crucial Hosting

Importing a MySQL Database

How to import an SQL dump file to a MySQL database using SSH.

  • Applies To: All Services
  • Difficulty: Easy
  • Software Required: None
AWS
This article was last updated on November 4th, 2015
mysql -u DBUSER -pDBPASS DBNAME < dump.sql

Replace text in uppercase with the appropriate information:

  • DBUSER - Database user with privileges to the database
  • DBPASS - Password for the database user
  • DBNAME - Database name

Please note, if your password contains special characters (* ? [ < > & ; ! | $), you will either need to escape them with a backslash, put the password between single quotes, or leave the password out (you'll be prompted to enter password). Here are some examples:

Escaped Password

mysql -u DBUSER -pM\*Y\?P\[A\<S\>S\&W\;O\!R\|D\$ DBNAME < dump.sql

Password In Quotes

mysql -u DBUSER -p'M*Y?P[A<S>S&W;O!R|D$' DBNAME < dump.sql

No Password

mysql -u DBUSER -p DBNAME < dump.sql

Professional hosting platform starting at $10/mo

View Plans