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

意思就是说,密码露了,不安全。

我们执行脚本的时候,最好可以把这个东西干掉,否则一直弹弹弹,烦的要死。

于是我们可以:

1. 建立一个文件,存放用户名、密码

touch /etc/my.password

然后写入下列内容:

[client]
user=root
password=密码

2. 登录时,不使用-u -p来指定,使用--defaults-extra-file=/etc/my.password来指定配置文件进行登录,就可以消掉那行warning了。

mysql --defaults-extra-file=/etc/my.password

猜你喜欢

转载自www.cnblogs.com/young233/p/12149996.html