mysql_config_editor使用簡介

神諭丶發表於2015-10-28
該工具可以建立一個"login-path",使用者可以直接通過login-path來登入mysql。
實質上,它儲存一個身份認證資訊到一個叫做.mylogin.cnf的的登入檔案中。

並且,該工具至少在mysql5.6.6以上的版本才可用。


建立一個login-path:

  1. shell> mysql_config_editor set --login-path=test --user=root --password --host=localhost
  2. Enter password:

建立好後,.mylogin.cnf將儲存在使用者的家目錄下,此處我用的是RHEL6,即/home/op下。
該檔案是不可讀的,它類似於選項組,包含單個身份的驗證資訊。

在登入mysql時,可以指定建立的login-path名,然後直接進入:
  1. shell> mysql --login-path=test
  2. Welcome to the MySQL monitor. Commands end with ; or \g.
  3. Your MySQL connection id is 4
  4. Server version: 5.6.26-log Source distribution
  5. …………………………………………………………

但是如果有人能夠拿到該檔案,通過一些方式,是可以將其破解並獲取你的密碼。

login-path只能被建立使用者使用(OS層面)。

如果想看.mylogin.cnf裡寫了什麼,可以使用:
  1. shell> mysql_config_editor print --all
  2. [test_login]
  3. user = root
  4. password = *****
  5. [test]
  6. user = root
  7. password = *****
  8. host = localhost
當然想只看某一個則可寫作
  1. shell> mysql_config_editor print --login-path=test
  2. [test]
  3. user = root
  4. password = *****
  5. host = localhost

若要刪除.mylogin.cnf,則可以使用
  1. 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  




作者公眾號(持續更新)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29773961/viewspace-1817640/,如需轉載,請註明出處,否則將追究法律責任。