最近运维过程中需要备份Mysql数据库,网上找bat脚本执行发现提示不能直接在脚本里放密码,Using a password on the command line interface can be insecure,应该是高级的mysql数据库的安全策略。
首先建一个bat文件
--defaults-extra-file=D:\MySQLBackUp\my.ini,将原来的sql语句放到ini文件中
@echo off set hour=%time:~0,2% if "%time:~0,1%"==" " set hour=0%time:~1,1% set now=%Date:~0,4%%Date:~5,2%%Date:~8,2%%hour%%Time:~3,2%%Time:~6,2% echo %now% set dbnamedhcp=dhcp_v2.1_gcp set backupfiledhcp=D:\MySQLBackUp\Dhcp\%dbnamedhcp%-%now%.sql "D:\mysql\mysql\bin\mysqldump" --defaults-extra-file=D:\MySQLBackUp\my.ini -c --add-drop-table %dbnamedhcp% > %backupfiledhcp%
然后创建一个my.ini文件,使用绝对路径,然后配置host账号密码,密码不可用带!等特殊字符,不然会登录不上
[client] host = localhost user = backup password = Backup1234@
然后在计划任务里,定时去跑bat就可以了
- 备份 interface password insecure command备份interface password insecure interface insecure password warning interactive interface command script interface command简介line insecure upgrade-insecure-requests upgrade-insecure-requests insecure requests xmlhttpreque requested insecure content global_id allowing insecure reclaim 靶场 实战insecure captcha