In this article we will show you how to export and import a MySQL database via SSH. Managing your databases via SSH is especially useful when dealing with large databases (over 50Mb).
1. Exporting a MySQL database
To export a MySQL database, you need to use the mysqldump command. Here is the full command for exporting your database:
mysqldump -uUSERNAME -pPASSWORD 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. The name of the MySQL dump you are exporting to can be whatever you want.
2. Importing a MySQL database
To import a MySQl database, you need to use the mysql command. Here is the full command for importing a MySQL dump into a database:
mysql -uUSERNAME -pPASSWORD 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.
- 1 Benutzer fanden dies hilfreich
Verwandte Artikel
Can I change the name of a MySQL database?
The name of a MySQL database consists of a prefix, which is your cPanel username, followed by a...
How can I change my MySQL database collation?
Usually you will be interested in changing your MySQL collation in order to solve problems with...
How can I empty a MySQL database?
The easiest way to empty a MySQL database is through phpMyAdmin. Once in phpMyAdmin, select the...
How to change the database engine of a MySQL database table?
In this article we will show you how to change the database engine of a MySQL table. Let's...
How to change the MySQL timezone
When you develop your website, you may have to compare a certain date/time with the current...