In MySQL server administration, it is important to safeguard your data in case of human error or a system failure. To accomplish this, MySQL provides the ability to create backups of databases and tables. In this lab, you will be tasked with creating backups for individual databases and tables, as well as full backups of the MySQL server. You will also need to demonstrate the ability to restore the MySQL server from a complete backup.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Create a Partial Backup of the prod Database That Only Includes the products Table
Run following command as
cloud_user
to create a backup of just theproducts
table in theprod
database:# mysqldump -u root -p prod products > prod_products.sql
- Create Full Backups of the dev and test Databases
Run following command to create backups of the
dev
andtest
databases:# mysqldump -u root -p --databases dev test > dev_test.sql
- Create a Complete Backup of All the Databases on the MySQL Server
Use the following command to create a full backup of all the databases on the MySQL server:
# mysqldump -u root -p --all-databases > full_backup.sql
- Create Delimited-Text Dump Files of the prod Database in the `/var/lib/mysql-files` Directory
Run the following command to create delimited-text dump files of the
prod
database in/var/lib/mysql-files
(the use ofsudo
does not require a password in this lab, so the prompt is for the MySQLroot
user, using the password Linux4me!:# sudo mysqldump -u root -p --tab=/var/lib/mysql-files/ prod
- Perform a Full Restore of the Databases on the MySQL Server by Reloading the msyql_dump.sql Dump File Located in the `/home/cloud_user` Directory
To perform a full restore of the MySQL server, run the following command from the
/home/cloud_user
directory:# mysql -u root -p < mysql_dump.sql