错误重现:

命令行或者shell脚本中执行以下命令,如果您当前服务器mysql版本是大于5.6的,则会出现警告:Warning: Using a password on the command line interface can be insecure. 这是mysql避免明文密码出现在脚本中做的安全提升

  1. mysqldump -h$ -u$ -p$ -P3306 -B ${dbnames} --single-transaction --triggers --routines --events --master-data= -F | gzip > $data_dir/$1_`date +%Y%m%d`.sql.gz

警告信息看着不爽,特别是crontab定时执行shell时,邮件会收到“原本该忽视”的stderr标准错误。

解决方案:

这里只说一个,利用 mysql_config_editor 进行预先设置连接信息,具体做法如下:

1、设置登录信息

  1. mysql_config_editor set --login-path=mall --host=mall.palcent.com --user=dumper -p

设置完毕,会在用户主目录%home%下生成一个.mylogin.cnf 文件,比如root用户,则生成 /root/.mylogin.cnf 。

2、查看当前主机上的加密文件

  1. mysql_config_editor print --all

3、使用加密文件

登录Mysql

  1. mysql --login-path=mall
  2. # Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is

备份数据库

  1. mysqldump --login-path=mall --databases ${dbnames} --single-transaction --triggers --routines --events --master-data= -F | gzip > $data_dir/$1_`date +%Y%m%d`.sql.gz

当然还有其他解决方案, 请自行参考以下参考链接!

参考链接:

https://www.cnblogs.com/rockbes/p/3972763.html (mysql_config_editor 用法)

https://blog.csdn.net/zxssoft/article/details/89667874

https://dev.mysql.com/doc/refman/8.0/en/password-security-user.html (官方解决方案)

mysql: "Warning: Using a password on the command line interface can be insecure." 解决方法的更多相关文章

  1. MySQL Warning: Using a password on the command line interface can be insecure.解决办法

    转自 http://www.cnblogs.com/sunss/p/6256706.html  被一个小朋友问到,直接公布答案: If your MySQL client/server version ...

  2. zabbix 3.4监控mysql,提示mysql: [Warning] Using a password on the command line interface can be insecure.

    mysql从5.6版本开始,如果是命令行直接出现了数据库连接密码就会有以下警告: mysql: [Warning] Using a password on the command line inter ...

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

    mysql: [Warning] Using a password on the command line interface can be insecure MySQL 5.6 警告信息 comma ...

  4. mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

    错误情况 解决办法: 首先查看mysql的命令 其次修改root用户的密码 set password for 'root'@'localhost' = password('123456'); 最后退出 ...

  5. Warning: Using a password on the command line interface can be insecure.解决办法

    被一个小朋友问到,直接公布答案: If your MySQL client/server version is a 5.6.x a way to avoid the WARNING message a ...

  6. MYSQL报警:Warning: Using a password on the command line interface can be insecure.

    问题描述:执行下面的语句,sql是执行成功了,但是出现了一个报警,报警看上去始终不舒服 mysql -hip -Pport -uuser -ppassword -e "use db;dele ...

  7. MYSQL5.7脚本运行时出现[Warning] Using a password on the command line interface can be insecure

    MYSQL版本:5.7 在写linux脚本执行MYSQL命令的时候,如果使用 MYSQL="mysql -hlocalhost -P3306 -uroot -p666666" 登陆 ...

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

    MySQL 5.6 在命令行输入密码,就会提示这些安全警告信息. Warning: Using a password on the command line interface can be inse ...

  9. mysql 备份报错mysqldump: [Warning] Using a password on the command line interface can be insecure.

    -------------------------------------------------------------------------------- mysql 备份报错mysqldump ...

随机推荐

  1. http请求报文格式(请求行、请求头、空行 和 请求包体)和响应报文格式(状态行、响应头部、空行 和 响应包体)

    转载 出处 超文本传输协议(Hypertext Transfer Protocol,简称HTTP)是应用层协议.HTTP 是一种请求/响应式的协议,即一个客户端与服务器建立连接后,向服务器发送一个请求 ...

  2. Vue实现active点击切换

    Vue实现active点击切换 循环的情况: 1.点击时传入index索引(获取当前点击的是哪个) @click=“active(index)” 2.将索引值传入class(索引等于几就第几个添加ac ...

  3. JVM垃圾回收算法图解

    参考文档:https://www.toutiao.com/a6691966641242112516/ 垃圾搜集算法 标记-清除法 标记-清除算法采用从根集合(GC Roots)进行扫描,对存活的对象进 ...

  4. postmaster - PostgreSQL多用户数据库服务器

    SYNOPSIS postmaster [ -A 0 | 1] [ -B nbuffers] [ -c name=value] [ -d debug-level] [ -D datadir] [ -F ...

  5. 获取服务进程server.exe的pid(0号崩溃)

    #include "stdafx.h" #include <windows.h> #include <iostream> #include <COMD ...

  6. 【Leetcode周赛】比赛目录索引

    contest 1 ~ contest 10: contest 11 ~ contest 20: contest 21 ~ contest 30 : https://www.cnblogs.com/z ...

  7. alert(1) to win 12

  8. AGC036C GP 2

    由于近期集训做的一直都是校内题 然后好久都怎么写题了( 发篇博客证明我还活着 (其实也没人关心 好像并不是很难的一道计数 就是脑子总是缺一块导致会做不出来( 首先我们可以分析性质 1.$\sum A_ ...

  9. centos 6.5 安装 maven

    从nexus官网下载Nexus Repository Manager OSS 2.x的安装包:nexus-2.14.1-01-bundle.tar.gz,3.x版本需要jdk8及以上 解压 tar x ...

  10. re模块的高级使用

    主要有四个方法: search : 从字符串的任意位置开始检索,首次匹配即结束 findall : 全部匹配 sub : 将正则匹配结果进行替换 split : 根据正则匹配结果将字符串进行切分,然后 ...