Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to export/import a MySQL database via SSH

If you have a large Database, you may face the issue to export/import large SQL database using phpMyAdmin or other interface.

In this article we will show you how to export/import SQL database via SSH. You can follow this steps if you have SSH access for your account.

1. Exporting a MySQL database via SSH

To export your Mysql Database, you need to use mysqldump command. You need to execute following command to export your database:

mysqldump -uUSERNAME -pPASSWORD DATABASE_NAME > DATABASE_BACKUP.sql

In the above command, you will have to update following details:

USERNAME = Your Mysql database user which has full permissions on your database
PASSWORD = Your MySQL database user’s password
DATABASE_NAME = Database name which you would like to backup

Above command will export your MySQL database in DATABASE_BACKUP.sql file. You can specify any file name.

2. Importing a MySQL database

To import your MySQL database via SSH, you need to use mysql command. You need to execute the following command to import your MySQL dump to a database:

mysql -uUSERNAME -pPASSWORD DATABASE_NAME < DATABASE_BACKUP.sql

In the above command, you will have to update following details:

USERNAME = Your MySQL database user which has full permissions on your database
PASSWORD = Your MySQL database user’s password
DATABASE_NAME = Database name which you would like to backup

If your backup file is uploaded in the different location, make sure that you specify the exact path for your database backup (i.e. /home/<user>/backup/DATABASE_BACKUP.sql).



This post first appeared on Web Hosting Blog - Web Hosting Discussion, please read the originial post: here

Share the post

How to export/import a MySQL database via SSH

×

Subscribe to Web Hosting Blog - Web Hosting Discussion

Get updates delivered right to your inbox!

Thank you for your subscription

×