MySQL 通過mysql_config_editor更安全的登入資料庫

haoge0205發表於2015-11-05
在5.6版本中,MySQL可以通過mysql_config_editor登入資料庫,變得更加安全。

[root@hank-yoon ~]# mysql_config_editor set --login-path=yoon --user=root --password

登入資料庫:
[root@hank-yoon ~]# mysql --login-path=yoon
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.26-log Source distribution


Copyright (c) 2000, 2015, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sakila             |
| test               |
+--------------------+
5 rows in set (0.02 sec)


mysql> 


檢視配置檔案,密碼直接被加密隱藏
[root@hank-yoon ~]# mysql_config_editor print --all
[yoon]
user = root
password = *****
host = localhost

通過vi去編輯檢視配置檔案,顯示一堆亂碼
[root@hank-yoon ~]# vi .mylogin.cnf
^@^@^@^@^D^F^R^N^D^[^R^E^F^N^L  ^O^P^E^L^A^N^Z^\^P^@^@^@?<99>??^Y&:7U<9e>^W^[^E?J?^P^@^@^@Y?J[??·°?|<90>?h?

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

相關文章