How To Backup and Restore MySQL Database Using Command Line

r00t April 7, 2014

How To Backup and Restore MySQL Database Using Command Line

This tutorial guide will show you two easy ways to backup and restore the data in your MySQL database using mysqldump. You can also use this process to move your data to a new web server. We assume that you already have MySQL installed on Linux system with administrative privileges and we assume that you already have a small amount of knowledge on MySQL.

The parameters of the said command as follows.

  • [uname] Your database username.
  • [passwd] The password for your database (note there is no space between -p and the password).
  • [dbname] The name of your database.
  • [backupdb.sql] The filename for your database backup.

Backup and Restore MySQL Database Using Command Line

Backup MySQL database

First, you can check MySQL databases from your server:

The following command will dump all databases to an sql file. Replace pass with your root database password and filename with the name of the file you wish to create such as backupdb.sql

Back up multiple databases in MySQL

Example:

Backup all databases in MySQL

Example:

Back up your MySQL Database with Compress

Example:

Restore MySQL database from a backup file

Above we backup the Tutorials database into backupdb.sql file. To re-create the Tutorials database you should follow two steps:

  • Create an appropriately named database on the target machine
  • Load the file using the mysql command:
Example:

MySQL DB Backup and Restore Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “MySQL DB Backup and Restore”, starting from $10 (Paypal payment). Please contact us to get a best deal!

Save

Share on Google+3Share on Facebook0Tweet about this on TwitterShare on Tumblr0Share on StumbleUpon2Share on Reddit1Pin on Pinterest1
The Tags:

Leave a Comment