標籤:
本文來自我的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=localhostEnter password:
建立好後,.mylogin.cnf將儲存在使用者的家目錄下,此處我用的是RHEL6,即/home/op下。該檔案是不可讀的,它類似於選項組,包含單個身份的驗證資訊。
在登入mysql時,可以指定建立的login-path名,然後直接進入:
shell> mysql --login-path=test-loginWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 4Server version: 5.6.26-log Source distribution…………………………………………………………
但是如果有人能夠拿到該檔案,通過一些方式,是可以將其破解並擷取你的密碼。
login-path只能被建立使用者使用(OS層面)。
如果想看.mylogin.cnf裡寫了什麼,可以使用:
shell> mysql_config_editor print --all[test_login]user = rootpassword = *****[test]user = rootpassword = *****host = localhost當然想只看某一個則可寫作shell> mysql_config_editor print --login-path=test[test]user = rootpassword = *****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 |
|
|
|
mysql之mysql_config_editor