本文来自个人github pages博客http://galengao.github.io/ 即www.gaohuirong.cnmysql
mysql_config_editor容许你把登陆的身份验证信息存储在一个名为.mylogin.cnf的文件里,该文件的位置在windows下是在%APPDATA%\MySQL目录下,linux下是在用户的家目录下。该文件可在之后经过MySQL客户端程序能够读取,以得到身份验证凭据用于链接到MySQL服务器。
mysql_config_editor容许你把登陆的身份验证信息存储在一个名为.mylogin.cnf的文件里,该文件的位置在windows下是在%APPDATA%\MySQL目录下,linux下是在用户的家目录下。该文件可在之后经过MySQL客户端程序能够读取,以得到身份验证凭据用于链接到MySQL服务器。
而且,该工具至少在mysql5.6.6以上的版本才可用。linux
shell> mysql_config_editor set --login-path=test --user=root --password --host=localhost Enter password:
建立好后,.mylogin.cnf将保存在用户的家目录下,此处我用的是RHEL6,即/home/op下。该文件是不可读的,它相似于选项组,包含单个身份的验证信息。git
shell> mysql --login-path=test-login Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.6.26-log Source distribution …………………………………………………………
可是若是有人可以拿到该文件,经过一些方式,是能够将其破解并获取你的密码。github
login-path只能被建立用户使用(OS层面)。sql
shell> mysql_config_editor print --all [test_login] user = root password = ***** [test] user = root password = ***** host = localhost 固然想只看某一个则可写做 shell> mysql_config_editor print --login-path=test [test] user = root password = ***** host = localhost
shell> mysql_config_editor remove --login-path=test
其余选项:shell
Format | Description | Introduced | ||||
–all | Print all login paths | |||||
–debug[=debug_options] | Write a debugging log | |||||
–help | Display help message and exit | |||||
–host=host_name | Host to write to login file | |||||
–login-path=name | Login path name | |||||
–password | Solicit password to write to login file | |||||
–port=port_num | TCP/IP port number to write to login file 5.6.11 | |||||
–socket=path | The Unix socket file name to write to login file 5.6.11 | |||||
–user=user_name | User name to write to login file | |||||
–verbose | Verbose mode | |||||
–version | Display version information and exit | |||||
–warn | Warn and solicit confirmation for overwriting login path |