mysql_config_editor

来源:互联网 发布:linux dd命令 编辑:程序博客网 时间:2024/05/29 16:54

从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