SSH- How to export/import a MySQL database via SSH

Question: How can we export/import a MySQL database via SSH commands?

Answer: we can export/import a MySQL database using below commands.

USERNAME - the MySQL user assigned to your database.

DATABASE - the name of your MySQL database.

1. Exporting a MySQL database

1
mysqldump -uUSERNAME -p DATABASE > backup.sql

2. Importing a MySQL database

1
mysql -uUSERNAME -p DATABASE < backup.sql

1 comment: