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

MYSQL版本:5.7mysql

在写linux脚本执行MYSQL命令的时候,若是使用linux

MYSQL="mysql -hlocalhost -P3306 -uroot -p666666"sql

登录并执行sql语句的时候,每次链接都会出现测试

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

很烦,不美观。因而开始找各类解决办法,无非是修改/etc/my.cnf文件,可是安装了mysql以后想执行这个脚本就得改文件那不更麻烦,更不美观。变量

解决方案:sql语句

在执行上述链接的时候:使用环境变量 MYSQL_PWD 快速登录command

MySQL优先会使用环境变量中的参数做为运行参数,因此必须使用export命令脚本

export MYSQL_PWD=666666word

那么在链接的时候就能够免密登录,例如:

MYSQL="mysql -hlocalhost -P3306 -uroot"

链接测试,成功。没有告警提示,不用修改文件,完美。

相关文章
相关标签/搜索