前幾天在試用mysql5.6.9主從功能的時候,發現在bin目錄中多了一個mysql_config_editor,
試用了一下,感覺很不錯,以後不用再重復輸入mysql用戶名密碼了。
[modify@H209 bin]$ pwd
/home/mysql569/bin
[modify@H209 bin]$ ./mysql_config_editor set --login-path=local569 --host=127.0.0.1 --user=root --password
Enter password:
[modify@H209 bin]$
[modify@H209 bin]$ ./mysql_config_editor print --all
[local569]
user = root
password = *****
host = 127.0.0.1
[modify@H209 bin]$ ./mysql --help | grep path
--ssl-capath=name CA directory (check OpenSSL docs, implies --ssl).
--ssl-crlpath=name Certificate revocation list path (implies --ssl).
--login-path=# Read this path from the login file.
ssl-capath (No default value)
ssl-crlpath (No default value)
[modify@H209 bin]$
[modify@H209 bin]$ ./mysql --login-path=local569
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.9-rc-log Source distribution
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> select user();
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)
mysql>
[modify@H209 bin]$ ll /home/modify/.mylogin.cnf
-rw------- 1 modify modify 136 01-08 14:07 /home/modify/.mylogin.cnf
.mylogin.cnf文件是加密過的,而且權限設置的很不錯。