Mysql database-defined Automatic Data Backup

Source: Internet
Author: User
Tags mysql tutorial

Mysql tutorial database tutorial definition Automatic Data Backup

MySQL installation path: D: AppServMySQL
Forum Database Name: flow
MySQL root Password 526888
Database Backup destination: F: Databackup

Program code

For/f "Tokens = 1 Delims =/" % I in ('date/t') do set dt = % I
For/f "Tokens = 1" % I in ('time/t') do set tm = % I
Set tm = % dt %
SET bkupdir = F: Databackup
SET mysqldir = D: AppServMySQL
Path D: AppServMySQLbin
SET dbname = flow
SET dbuser = root
SET dbpassword = 526888
SET CharacterSet = utf8
@ ECHO Beginning backup of % dbname %...
Mysqldump-u % dbuser %-p % dbpassword % dbname % -- add-drop-table -- complete-insert -- opt> % bkupdir % dbname %-% tm %. SQL
@ ECHO Done! New file: % bkupdir % dbname %-% tm %. SQL

 


Save the preceding code as backup_db.bat.
Then, run the script periodically using the "scheduled task" of Windows. (For example, execute back_db.bat at every day)

1. Enable related services.
Open "Control Panel"-"Management Tools" (if you use a new classification view, you must first open "performance and maintenance")-"service", and a table will be displayed, you can find the "Task Scheduler" item in it. If it is "disabled", you need to start the service. The method is to right-click "attribute" and change "disabled" to "Manual" or "automatic" (manual means that you need to start it again when you start the system next time, automatic means that the service is automatically enabled every time the computer is started), and then click the "Start" button under "OK;

2. Ensure permissions and Set passwords and related settings.
If you have to set a boot password for your computer, you cannot set the boot password alone. The specific method is: first set a boot password for your computer (Note: You need to have administrator permissions, otherwise you don't want to use it), and then follow the steps above to open it, the difference is that what we want to open is not a "service" but a "Local Security Policy". After opening it, select "Local Policy" and "Security Options ". Then, find "account: Local Account With Blank Password" in the table on the right. If this item is already "enabled", change it to "disabled ".

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.