Exporting and Importing MySQL Database using SSH
You will need to have shell access enabled to follow this tutorial, click here for a guide on enabling SSH
Exporting A MySQL Database
Step 1 - Log in via SSH.
Step 2 - Enter the following command, replacing username with the database username and database_name with the name of the database. If you don't know these details, you can find them using this guide.
mysqldump -p -u username database_name > database_name.sql
Step 3 - You will be prompted for a password. Type in the database user's password and press Enter.
The file database_name.sql will be generated in your now holds a backup of your database and is ready for download to your computer.
To export a single table from your database you would use the following command:
mysqldump -p --user=username database_name tableName > tableName.sql
As before, you would need to replace the username, database, and tableName with the correct information. Once done the table specified would then be saved to your account as tableName.sql
Import A MySQL Database
Step 1 - Upload the .sql file onto the server.
The file must be in .sql format. It can not be compressed in a .zip or .tar.gz file.
Step 2 - If you haven't already done so, create the MySQL database via your Control Panel
Step 3 - Using SSH, navigate to the directory where your .sql file is.
Step 4 - Run this command, replacing username with the database username and database_name with the name of the database. If you don't know these details, you can find them using this guide.:
mysql -p -u username database_name < file.sql
To import a single table into an existing database you would use the following command:
mysql -u username -p -D database_name < tableName.sql
Did you find this article useful?