mysql_config_editor可以给指定的连接和密码生成一个加密文件.mylogin.cnf,默认位于当前用户家目录下。mysql、mysqladmin等可以使用该文件直接登录,避免明文密码出现在脚本中。
如果没有指定 --login-path, mysql_config_editor 默认读 client login path
scutech@scutech:~$ mysql_config_editor set --login_path=client --host=localhost --user=root --password Enter password: scutech@scutech:~$ mysql_config_editor print --all [scutech] user = root password = ***** host = localhost [path1] user = root password = ***** host = localhost [client] user = root password = ***** host = localhost scutech@scutech:~$ mysql_config_editor remove --login-path=client scutech@scutech:~$ mysql_config_editor print --all [scutech] user = root password = ***** host = localhost [path1] user = root password = ***** host = localhost scutech@scutech:~$
mysql_config_editor print 默认也是显示client login path
$ mysql_config_editor print [client] user = root password = ***** host = localhost
在mysql的客户端里面还可以在命令行里面指定部分在login-path里面已经设置了的参数,指定的参数优先,例如:
mysql --login-path=path1 --host=192.168.17.149