MySQL5.6 Using a password on the command line interface can be insecure解决方法;

1.最近把MySQL从5.5升到5.6以后,mysqldump居然不好用了,提示:

[root@qttc ~]# /usr/local/mysql/bin/mysqldump  -uroot -proot db > bak.sql
Warning: Using a password on the command line interface can be insecure.

翻译过来是:在命令行界面上使用密码可以是不安全的;

这让人有点郁闷,5.5用的1直都很爽,到5.6居然说命令行方式写密码不安全?那密码写哪呢?

在官网文档找到了缘由,大家可以点击这里看看:

1.官方网址:http://dev.mysql.com/doc/refman/5.1/en/password-security-user.html

MySQL users shoulduse the following guidelines to keep passwords secure.

   When you run a client program to connect to the MySQL server, it is inadvisableto specify your password in a way that exposes it to discovery by other users.The methods you can use to specify your password when you run client programsare listed here, along with an assessment of the risks of each method. Inshort, the safest methods are to have the client program prompt for thepassword or to specify the password in a properly protected option file.

翻译过来大意是在命令行下如果要使用密码可以在执行命令后的提示输入里输入密码,或者在指定的安全文件内指定密码;那安全文件时哪个呢?文档对此给出了答案:

Store your passwordin an option file. For example, on Unix, you can list your password in the[client] section of the .my.cnf file in your home directory:

可以在my.cnf内指定,于是打开我的my.cnf,在[mysqldump]下增加:

user=root
password=root

文中说的在[client]下面加也可以,但那样就所有块的操作都能共享了,所以生产环境上为了安全还是尽量分开;保存退出再dump就ok了;

[root@qttc ~]# /usr/local/mysql/bin/mysqldump db > bak.sql
[root@qttc ~]#

MySQL 5.6 警告信息 command line interface can be insecure 修复

在命令行输入密码,就会提示这些安全警告信息;

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

注:mysql -u root -pPASSWORD 或 mysqldump -u root -pPASSWORD 都会输出这样的警告信息.

1.针对mysql:

mysql -u root -pPASSWORD改成mysql -u root -p 在输入密码即可.

2.mysqldump就比较麻烦了,通常都写在scripts脚本中;

解决方法:

对于mysqldump 要如何避免出现(Warning:Using a password on the command line interface can be insecure.) 警告信息呢?

vim /etc/mysql/my.cnf

[mysqldump]

user=your_backup_user_name

password=your_backup_password

修改完配置文件后, 只需要执行mysqldump 脚本就可以了;备份脚本中不需要涉及用户名密码相关信息;

作者:wk814007042
来源:CSDN
原文:https://blog.csdn.net/wk1063645973/article/details/49562697
版权声明:本文为博主原创文章,转载请附上博文链接!

所有原创文章采用 知识共享署名-非商业性使用 4.0 国际许可协议 进行许可。
您可以自由的转载和修改,但请务必注明文章来源并且不可用于商业目的。
本站部分内容收集于互联网,如果有侵权内容、不妥之处,请联系我们删除。敬请谅解!

添加新评论

  关于博主

当你发现自己的才华撑不起野心时,就请安静下来学习吧

  近期评论

  •  oevsgwftiw: 这篇文章不错!
  •  tptzkwumow: 这篇文章不错!
  •  higxcaasal: 这篇文章不错!
  •  gbkzxsngnm: 这篇文章不错!
  •  amozacdtyp: 作者的才华横溢,让这篇文章成为了一篇不可多得的艺术品。
  •  jpxtzzllvr: 内容的丰富性和深度让人仿佛置身于知识的海洋,受益匪浅。
  •  wjlsiejlxz: 作者的观点新颖且实用,让人在阅读中获得了新的思考和灵感。
  •  vlbfsfopgo: 建议引入反面案例,增强辩证性。
  •  qspdecneno: 跳出常规思维,角度独特,令人耳目一新。
  •  cuokmcjfrz: 建议控制调侃频率,避免消解主题深度。

只有脚踏实地的人,才能够说:路,就在我的脚下。

无论你选择做什么,追求完美的程度决定你成就的高度。

这个世界最脆弱的是生命,身体健康,很重要。

上帝说:你要什么便取什么,但是要付出相当的代价。

现在站在什么地方不重要,重要的是你往什么方向移动。