This backups can be automated using the cron job. Here i am using the manual utility “mysqldump” for taking the backup and restoring the database.
Backup MySQL Database:
Syntax:
mysqldump -h [hostname] -u [username] -p[password] [database] > [backup_file]
There should not be any space between -p and password.
Example:
mysqldump -h localhost -u root -pP@ssw0rd@$52 dbase01 > dbase01.sql
Once backup done, If required you can restore by using the following command.
Restore MySQL Database:
Syntax:
mysql -h [hostname] -u [username] -p[password] [database] < [backup_file]
Example:
mysql -h localhost -u root -pP@ssw0rd@$52 dbase01 < dbase01.sql
That’s All. You can also use the phpMyAdmin to backup and restore databases.
mysqldump -h localhost -u root -pP@ssw0rd@$52 dbase01 < dbase01.sql
mysqldump not use for undump.