When dealing with large databases over 128MB it is recommended to manage them via SSH. More information on how to connect to and use SSH is available in this SSH Tutorial.
In this article, we will cover exporting and importing a database via SSH. Make sure that you replace the following variables in the commands below:USERNAME – the MySQL user assigned to your database.
DATABASE – the name of your MySQL database.
- Exporting a MySQL database
To export a MySQL database, use the mysqldump command. Here is the full command for exporting your database:
mysqldump -uUSERNAME -p DATABASE > backup.sql
You will be prompted for a password – this is your MySQL user’s password.
The MySQL database will be exported to a file named “backup.sql” in your current directory.
- Importing a MySQL database
To import a MySQL database, use the mysql command. Here is the full command:
mysql -uUSERNAME -p DATABASE < backup.sql
Again, you will be prompted for the password of your MySQL user.
The backup.sql is the name of the file that you are importing to your database. It must be in your current working directory.
Post a Comment for "How to export/import a MySQL database via SSH?"