mysqldump: [Warning] Using a password on the command line interface can be insecure.

数据库备份写入过程中

源代码:

[root@localhost ~]# mysqldump -uroot -pMyNewPass4! -F -B it --default-character-set=utf8 --single-transaction -e | gzip > /root/mysql_back_`date +%F`.sql.gz

警告信息1:

Warning: Using a password on the command line interface can be insecure.

意思是说:在命令行界面上使用密码可能是不安全的,不能直接把密码写在脚本中。

解决办法:

既然密码不能直接外露,那么我们就写在/etc/my.cnf下面:

[root@localhost ~]# vim /etc/my.cnf
添加自己的信息,注意socket的位置

[client]
port=3306
socket=/var/lib/mysql/mysql.sock
default-character-set = utf8mb4
host = localhost
user = root
password = 'MyNewPass4!'

可以通过find / -name mysql.sock 查找具体位置,修改用户密码部分

mysqldump --defaults-extra-file=/etc/my.cnf -F -B it --default-character-set=utf8 --single-transaction -e | gzip > /root/mysql_back_`date +%F`.sql.gz

警告信息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. 

在上面的脚本中加入 --set-gtid-purged=off 或者–gtid-mode=OFF这两个参数设置就可以了。

  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值