-
SQL code
-
-- Or database shard backup, but what if I want to exclude the specified database from the first database? -- Do you have to control the for loop by logic judgment? -- instead, I first use SQL statements to get the names of all the databases currently and create backup statements, -- Can I more flexibly exclude the specified database from backup in SQL statements? -- I think: this is also a more flexible method than yours! ---- In windows, My SQL automatically backs up all databases by database: -- assume that I back up the daily backup files in the D: \ mysql_bk \ 20110818 directory (note: 20110818 is the date of the day's backup) -- Step 1: Create a mysql_bk. SQL file in the D: \ mysql_bk directory. The content of this file is as follows: Select T. bk_sqlfrom (select Concat ('If exist "', 'd: \/mysql_bk \/', date_format (curdate (), '% Y % m % D '), '"rmdir/S/Q" D: \/mysql_bk \/', date_format (curdate (), '% Y % m % D'),' "') as bk_ SQL, 1 As pai_order Union all select Concat ('md "', 'd: \/mysql_bk \/', date_format (curdate (), '% Y % m % D '), '"') as bk_ SQL, 2 as your _order Union all select Concat ('mysqldump-uroot-pgroupon1 @ 3 $ ', Schema_name,'> ','" ', 'd: \/mysql_bk \/', date_format (curdate (),' % Y % m % D'), '\/', Schema_name, '_', date_format (curdate (), '% Y % m % D '),'. SQL ',' "') as bk_ SQL, 3 as cmd_orderfrom information_schema.schemata) torder by T. pai_order ascinto OUTFILE 'd:/mysql_bk/mysql_dump.bat '; -- Step 2: Create a mysql_bk.bat file in the D: \ mysql_bk directory. The content of this file is as follows: if exist "D: \ mysql_bk \ mysql_dump.bat "del/S/Q" D: \ mysql_bk \ mysql_dump.bat "mysql-uroot-pgroupon1 @ 3 $ information_schema <D: \ mysql_bk \ mysql_bk.sqlcall D: /mysql_bk/mysql_dump.bat/C/q -- Step 3: create a task plan and execute the mysql_bk.bat file at every day.
-- It is very practical to see this post, and I also paste my solution, hoping to help you!
Http://topic.csdn.net/u/20110817/18/2316517f-25a6-410b-b557-587d4369d833.html
Http://topic.csdn.net/u/20110817/16/22164a37-773f-47f3-973f-8bdca3cd7f69.html