本文來自個人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 |