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

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

1Exporting 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 -u USERNAME -p PASSWORD 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.

2Importing 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 -u USERNAME -p PASSWORD 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.

  • 0 Users Found This Useful
這篇文章有幫助嗎?

相關文章

How do I park a domain name?

Add a Parked domain:Step 1. To access the Parked Domains feature, click on the corresponding icon...

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

Step 1. Log in to your cpanelStep 2. Under the Databases heading, click the MySQL Databases...

How to create a Mysql database?

Creating a PostgreSQL database is a straight-forward process. All you need to do is log in to...

How to create a Mysql user?

In order to create a MySQL user you should go to your cPanel -> MySQL Databases interface.In...

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