How do I restore a MySQL database from an sql dump?
This article shows how to restore MySQL databases on the commandline easily. If your MySQL user has a password, then use this command:
mysql -h localhost -u [MySQL user, e.g. root] -p[database password] [name of the database] < [name of your sql dump, e.g. sqldump.sql]
Please note: there's no space between -p and the password!
If there's no password:
mysql -h localhost -u [MySQL user, e.g. root] [name of the database] < [name of your sql dump, e.g. sqldump.sql]
The above commands are compatible with all Linux distributions incl. CentOS, Fedora, Arch Linux, OpenSuSE, etc.
On Debian and Ubuntu you can use the debian-sys-maint login to restore the MySQL database, so you dont have to remember the MySQL password.
Example:
sudo mysql --defaults-file=/etc/mysql/debian.cnf [name of the database] < [name of your sql dump, e.g. sqldump.sql]