How to export or import a MySQL database via SSH

Importing a MySQL database

To import a MySQL database, use the mysql command.

mysql -u USERNAME -p PASSWORD DATABASE < backup.sql

Make sure you replace USERNAME, PASSWORD and DATABASE with the appropriate values for your database. For DATABASE you must use an existing database.

Exporting a MySQL database

To export a MySQL database, use the mysqldump command.:

mysqldump -u USERNAME -p PASSWORD DATABASE > backup.sql

Make sure you replace USERNAME, PASSWORD and DATABASE with the appropriate values for your database. The MySQL database will be exported to a file named "backup.sql" in your current directory.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments