mysql_config_editor

从Mysql5.6.6 开始mysql_config_editor允许存储加密的身份验证文件.mylogin.cnf

.mylogin.cnf在系统中的位置
Windows :%APPDATA%\MySQL
Linux:$HOME/.mylogin.cnf

1.用mysql_config_editor生成.mylogin.cnf
$mysql_config_editor set --login-path=3336 -S /mysqlweb/mysql3336/logs/mysql.sock  --user=root --password
Enter password:

$mysql_config_editor set --login-path=3326 --host=127.0.0.1 -P3326 --user=root --password
Enter password:


$ls  ~/.mylogin.cnf   
/home/mysql/.mylogin.cnf

2.查看.mylogin.cnf的内容
$mysql_config_editor print --all
[3336]
user = root
password = *****
socket = /mysqlweb/mysql3336/logs/mysql.sock
[3326]
user = root
password = *****
host = 127.0.0.1
port = 3326
在.mylogin.cnf中密码是经过加密的。

3.使用mysql_config_editor中设置的login-path登录mysql
$mysql --login-path=3326 -e"show variables like'port'\G"
*************************** 1. row ***************************
Variable_name: port
        Value: 3326
       
$mysql --login-path=3336 -e"show variables like'port'\G"
*************************** 1. row ***************************
Variable_name: port
        Value: 3336         
       
参考文档:
http://dev.mysql.com/doc/refman/5.6/en/mysql-config-editor.html       

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值