mysql_config_editor使用简介

 
 
--------------------------------------------------------------------------------------------------------------
 

分类: MySQL

2015-10-28 18:57:21

 
该工具可以创建一个"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



其他选项:

FormatDescriptionIntroduced
--allPrint all login paths 
--debug[=debug_options]Write a debugging log 
--helpDisplay help message and exit 
--host=host_nameHost to write to login file 
--login-path=nameLogin path name 
--passwordSolicit password to write to login file 
--port=port_numTCP/IP port number to write to login file5.6.11
--socket=pathThe Unix socket file name to write to login file5.6.11
--user=user_nameUser name to write to login file 
--verboseVerbose mode 
--versionDisplay version information and exit 
--warnWarn and solicit confirmation for overwriting login path 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值