In Linux, database backup is very important. If regular backup is performed, the data can be restored to the last normal state in the case of a system crash, minimizing the loss. MySQLl provides a mysqldump command, which can be used for data backup. The following assumes that you want to back up the tm database:
# Mysqldump-u root-p tm> tm_050519. SQL
Enter the password as prompted, and back up all the table structures and data of the tm database to tm_050519. SQL. Because the backup work is always required, if the data volume occupies a large space, in this case, you can use gzip to compress data. The command is as follows:
# Mysqldump-u root-p tm | gzip> tm_050519. SQL .gz
When the system crashes and the system is rebuilt, data can be restored as follows:
# Mysql-u root-p tm <tm_050519. SQL
Direct Recovery from compressed files:
# Gzip <tm_050519. SQL .gz | mysql-u root-p tm
Of course, many MySQL tools provide more intuitive backup and recovery functions, such as phpMyAdmin. However, I think mysqldump is the most basic and common.
2. Using crontab, the system regularly backs up mysql Databases every day.