Backing up and restoring a MySQL database
This recipe shows you how to back up your MySQL databases using
mysqldump. The utility connects to the MySQL server, queries the structure of the database and its data, and outputs the data in the form of SQL statements. The backup can then be used to restore the database or populate a new database with the data.
This recipe requires a running MySQL server and access to either MySQL's
root user or another user with the necessary privileges to perform the backup.
How to do it...
Follow these steps to make a backup of a MySQL database:
- Connect to the MySQL database you want to back up:
mysql -u root -p packt
- Execute a
FLUSH TABLESstatement to set the database's tables read-only:
FLUSH TABLES WITH ...