Categories
Tools

MYSQL database backup and restore using command line

Last updated on May 5th, 2016 at 01:13 am

Click to rate this tutorial!
[Total: 0 Average: 0]

MYSQL database backup and restore, Taking mysql database backups are always crucial now a days as daily and weekly backups are always recommended. We are using mysqldump command here to take the backups and also to restore them. Please find the steps below on how to take MYSQL database backup and restore using command line.

mysqldump -u <USERNAME> -p <PWD> <DATABASE_NAME> > <DATABASE_NAME>_BACKUP.sql

Here
USERNAME -> Your database user name
PWD -> Your database password
DATABASE_NAME -> Your database name

For example if i have a database name MYDATA and username as root and password as root123 then the command will look like

#mysqldump -u root -p root123 MYDATA > MYDATA_BACKUP.sql

It is not recommended to provide password in one single command. You can use the command like the one shown below and once the password is prompted you can provide that.
By doing this you are not saving any password in the user command history and no one else can see the password. So it is a security feature and it is always up to you to decide how to go forward with that.

#mysqldump -u root -p MYDATA > MYDATA_BACKUP.sql
Enter Password:
Click to rate this tutorial!
[Total: 0 Average: 0]

Leave a Reply

Your email address will not be published.