How to backup and restore MySQL DBs via Command line

It is possible to back up and restore MySQL DBs via the server command line. We are usually using the 'mysqldump' command to take the backup of a database from the command line interface. You can watch the video tutorial by clicking here

Backup a DB:

# mysqldump db_name > db_name.sql

Or by specifying the username and password

# mysqldump -u user -p db_name > db_name.sql

Restore a DB:


# mysql db_name < db_name.sql

You need to provide the DB name to be restored in the first place and then after the '<' symbol, provide the backup file name or the full path.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How To Install and Use Docker on Ubuntu 16.04

Introduction Docker is an application that makes it simple and easy to run application processes...

Change Main IP of the server :: Vesta Panel

If we are changing the main IP of a server installed with Vesta panel, we can use the following...

cPanel: Apache-FastCGI Data Timeout Error

If you are using a cPanel server and have FastCGI enabled in Apache, you might be facing the...

Domainkey installer in cPanel

You can use the following cPanel script to install domainkey for an account...

Email issues :: Common Troubleshooting Steps

Here I will discuss some common errors and their solution: We are using a mail relay setup for...