Backing Up and Restoring MySQL Dumps!

Hi Guys who are a novice to the DevOps Industry or Experts come across instances where they need to take a backup of the database, so today my article is about how to take a MySQL Backup and to restore it. These commands are all done through the terminal where MySQL resides.

Image Courtesy —
  1. Taking a Backup

mysqldump -u {username} –p {password} {database_name} > {dump_file.sql}

When taking this command more closely, the values within curly brackets should be replaced with appropriate values.

  • mysqldump → the command it will execute

ps — It's a best practice that you name the dump file as follows, the database name followed by the date and time it was taken and storing it inside a folder dedicated for database backups.

  • example → DatabaseName-DDMMYYYY:HHMM

2. Restoring the Backup

Initially locate where you have stored the backup, and enter the following command the values of the curly brackets should be,

MySQL -u {username} –p{password} {database_name} < {dump_file.sql}

As in the previous command,

  • MySQL → the command type to execute

I hope this will be helpful to make your work efficient and easy! Stay Safe and Keep Going! Never Give Up!

Im a DevOps Engineer who is trying to enhance my knowledge as well as help my fellow DevOps acquaintances with knowledge on job related tasks!