本文來自我的github pages博客http://galengao.github.io/ 即www.gaohuirong.cn
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以上的版本才可用。
創建一個login-path:
shell> mysql_config_editor set --login-path=test --user=root --password --host=localhost Enter password:
創建好后,.mylogin.cnf將保存在用戶的家目錄下,此處我用的是RHEL6,即/home/op下。該文件是不可讀的,它類似於選項組,包含單個身份的驗證信息。
在登錄mysql時,可以指定創建的login-path名,然后直接進入:
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 …………………………………………………………
但是如果有人能夠拿到該文件,通過一些方式,是可以將其破解並獲取你的密碼。
login-path只能被創建用戶使用(OS層面)。
如果想看.mylogin.cnf里寫了什么,可以使用:
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
若要刪除.mylogin.cnf,則可以使用
shell> mysql_config_editor remove --login-path=test
其他選項:
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 |