数据库备份出现警告:Warning: Using a password on the command line interface can be insecure. Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even thos
1.先来看原备份数据库语句:
1 mysqldump -h 127.0.0.1 -uroot -ppassword database > /usr/microStorage/dbbackup/capsule_prod$(date +%Y%m%d_%H%M%S).sql
警告信息1:
Warning: Using a password on the command line interface can be insecure.
意思是说:在命令行界面上使用密码可能是不安全的,不能直接把密码写在脚本中。
解决方法:
在/etc/my.cnf中配置用户名与密码
1 [client] 2 port = 3306 3 socket = /tmp/mysql.sock 4 default-character-set = utf8mb4 5 host = localhost //地址 6 user = root //用户 7 password = 'myServerPwd' //密码
现在备份数据库语句为:
1 mysqldump --defaults-extra-file=/etc/my.cnf database > /usr/microStorage/dbbackup/capsule_prod$(date +%Y%m%d_%H%M%S).sql
目前第一个警告解决。
警告信息2:
Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete dump, pass --all-databases --triggers --routines --events.
关于GTID是5.6以后,加入了全局事务 ID (GTID) 来强化数据库的主备一致性,故障恢复,以及容错能力。
官方给的:A global transaction identifier (GTID) is a unique identifier created and associated with each transaction committed on the server of origin (master).
解决方法:
在上面的脚本中加入 --set-gtid-purged=off 或者–gtid-mode=OFF这两个参数设置
现在备份数据库语句为:
1 mysqldump --defaults-extra-file=/etc/my.cnf --set-gtid-purged=off microstorage_backend > /usr/microStorage/dbbackup/capsule_prod$(date +%Y%m%d_%H%M%S).sql
以上两个警告解决。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix