How to export/import a MySQL database via SSH

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).

SiteGround customers can find more information on how to connect to and use SSH in our SSH tutorial.

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.

cPanel is easy to work with when you have the right host to support you. If you need a reliable partner to help you manage your website with cPanel, check out our cPanel hosting services!

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Error about legacy type authentication (old-style) when connecting remotely to MySQL

This particular error can occur in some MySQL clients. The reason for it is that our servers...

How to change the password of a Mysql user in cPanel?

If you have already created a MySQL user through the cPanel -> Mysql Databases tool you may...

How to reset the password for a MySQL database?

You may need to change the password of your database in order to improve the security of your...

I cannot create views in MySQL

Regular MySQL users do not have privileges to create views in MySQL. If you try to execute CREATE...

What are MySQL triggers and how to use them?

he MySQL trigger is a database object that is associated with a table. It will be activated when...