A Guide to Import and Export MySQL Database via SSH

Thursday, 26 July 2018
(2 votes)

 How to import and export MySQL database via SSH

You can easily import/export your database using phpMyAdmin menu in cPanel, but when dealing with large databases over 50Mb it is recommended to manage them via SSH. In this article, I 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, you need to 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, you need to 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.

Video Tutorial

Is it not a great idea to follow me to be recieve my last posts? Follow me now!

3120 times

Friday, 27 July 2018

Ibrahim Jabbari

I am Ibrahim Jabbari Web Designer / Developer since 2006, This is my blog, I'll share my experiences, Useful resources and all update news from IT world with you all, I hope you enjoy surfing my blog. Connect with me on Facebook, Twitter and and Instagram.