MySQL 5.6 Warning - Using a password on the command line interface can be insecur 解决方案
作者: 曲文庆 日期: 2015-04-23 11:52
Warning: Using a password on the command line interface can be insecur
MySQL 5.6 版本对安全性进行了增强,如果在命令中使用了 -ppassword ,就会有告警提示:Warning: Using a password on the command line interface can be insecure;
那么问题来了,我们经常用脚本完成一些工作,例如备份、监控、检测等等,不同工作可能采用不同的MySQL用户及权限,常用方式都是采用 -uusername -ppassword 内置到脚本中,这样就会触发告警。
如何解决呢?总结了一下,可以采取如下几种方案:
方案一:将权限写到配置文件里,通过 --defaults-extra-file= 方式加载。
方案二:通过MySQL 5.6 新增命令 mysql_config_editor (http://dev.mysql.com/doc/refman/5.6/en/mysql-config-editor.html) 来预置相关权限信息
方案三:将告警信息输出到文件或丢弃,采用 2>/dev/null 或 2>/path/file 等方式,简单粗暴有效,但容易忽略掉其他告警信息
方案四:通过环境变量存储密码,export MYSQL_PWD=password ; mysql -uusername ,该方案简单有效,推荐之
Converting HEAP to MyISAM (2014-10-30 19:06)
MySQL Error 2006 MySQL server has gone away原因分析 (2014-10-29 16:55)
Install Atlas in CentOS 6 (2014-03-12 12:01)
mysqldump 出現general_log 錯誤 (2011-01-07 20:24)
mysql导出符合条件的数据(含字符集) (2010-11-03 10:04)
深入了解MySQL 5.5分区功能增强 (2010-05-19 10:18)
MySQL /bin/rm: cannot remove `libtoolT': No such file or directory (2010-05-19 09:57)
MySQL配置文件my.cnf (2009-12-29 22:29)
MySQL创始人力劝用户暂缓部署MySQL 5.1 (2008-12-03 09:10)