Using scheduled tasks in linux to regularly back up mysql database bitsCN.com
Using scheduled tasks in linux to regularly back up mysql databases
# Crontab-e
Add a row:
10 05 *** mysqldump-u database user-p password-A/home/back. SQL -- lock-tables = 0
# Wq
Explanation:
Run the mysqldump command at 05:10 every day. Note that-u is followed by no space and the username-p is followed by the password.
Here, the mysqldump command:
Use the specified database user and password.-A indicates that all databases are backed up to the/home/back. SQL file. -- lock-tables does not lock the table during backup.
In this way, at 05:10 every day, the system will back up all the data in the database under the specified database user permission to an SQL file.
Recover data:
Mysql -- default-character-set = utf8 dbname-u username-p password [Database name]
BitsCN.com