Mysql regular backup in CentOS

Source: Internet
Author: User

1. Backup statement

[Plain] view plaincopy
  1. #/Usr/local/mysql/bin/mysqldump-utest-ptesttest -- socket =/tmp/mysql.3306.sock>/usr/local/mysql_backup/3306/test-'date1_policy1_m1_d'. SQL .gz

Statement description:

  • /Usr/local/mysql/bin/mysqldump: Under the MySql installation directory
  • -Utest: divided into two parts, one of which is-u and the other is test. The-u table shows that it is the user name, and the test table shows that it is the current user name.
  • -Ptest: it can be divided into two parts, one of which is-u and the other is test. The-u table shows it as the password, and the test indicates the current password.
  • -- Socket: Specifies the port to be backed up. Check which of the following matches the port/tmp.
  • Test: Which database to back up
  • >: The folder to which the backup is stored and named after the database name-current date.

2. Write the statement into a script.

3. edit/etc/crontab

[Plain] view plaincopy
  1. # Vim/etc/crontab

4. Add

[Plain] view plaincopy
  1. 003 *** root/home/mysql/3306/backup

Note: backup is the script you just wrote.

Indicates that a backup is performed at three o'clock every day.

5. Restart crontab

[Plain] view plaincopy
  1. #/Etc/rc. d/init. d/crondrestart

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.