MySQL 5.6 配置安全的加密密碼
在shell指令碼中,通常要配置資料庫的明文密碼,這是不安全的。在MySQL 5.6版本以後,可以配置安全的加密密碼檔案,之後可以使用加密後的密碼檔案連線資料庫,而不需要輸入明文密碼。
為本地root使用者配置安全加密密碼
[root@localhost ~]# mysql_config_editor set --user=root --password
Enter password:
嘗試連線資料庫
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 179
Server version: 5.6.31-77.0-log Percona Server (GPL), Release 77.0, Revision 5c1061c
Copyright (c) 2009-2016 Percona LLC and/or its affiliates
Copyright (c) 2000, 2016, 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> select user();
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)
mysql> exit
Bye
到家目錄,檢視加密密碼檔案,可以看到裡面的亂碼
[root@localhost ~]# cd
[root@localhost ~]# cat .mylogin.cnf
?
?#[root@localhost ~]# p_?EQ!?a\S??T SB??hH?XJ?-&?P?-/?|m5?
配置指定的遠端資料庫連線使用者
[root@localhost ~]# mysql_config_editor set --login-path=remote --host=192.168.56.101 --user=ss7 --password
Enter password:
檢視配置過的加密密碼清單
[root@localhost ~]# mysql_config_editor print --all
[client]
user = root
password = *****
[remote]
user = ss7
password = *****
host = 192.168.56.101
嘗試連線資料庫
[root@localhost ~]# mysql --login-path=remote
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 181
Server version: 5.6.31-77.0-log Percona Server (GPL), Release 77.0, Revision 5c1061c
Copyright (c) 2009-2016 Percona LLC and/or its affiliates
Copyright (c) 2000, 2016, 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> select user();
+--------------------+
| user() |
+--------------------+
| ss7@192.168.56.101 |
+--------------------+
1 row in set (0.00 sec)
mysql> exit
Bye
透過--login-path選項連線root本地使用者
[root@localhost ~]# mysql --login-path=client
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 182
Server version: 5.6.31-77.0-log Percona Server (GPL), Release 77.0, Revision 5c1061c
Copyright (c) 2009-2016 Percona LLC and/or its affiliates
Copyright (c) 2000, 2016, 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> select user();
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)
為本地root使用者配置安全加密密碼
[root@localhost ~]# mysql_config_editor set --user=root --password
Enter password:
嘗試連線資料庫
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 179
Server version: 5.6.31-77.0-log Percona Server (GPL), Release 77.0, Revision 5c1061c
Copyright (c) 2009-2016 Percona LLC and/or its affiliates
Copyright (c) 2000, 2016, 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> select user();
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)
mysql> exit
Bye
到家目錄,檢視加密密碼檔案,可以看到裡面的亂碼
[root@localhost ~]# cd
[root@localhost ~]# cat .mylogin.cnf
?
?#[root@localhost ~]# p_?EQ!?a\S??T SB??hH?XJ?-&?P?-/?|m5?
配置指定的遠端資料庫連線使用者
[root@localhost ~]# mysql_config_editor set --login-path=remote --host=192.168.56.101 --user=ss7 --password
Enter password:
檢視配置過的加密密碼清單
[root@localhost ~]# mysql_config_editor print --all
[client]
user = root
password = *****
[remote]
user = ss7
password = *****
host = 192.168.56.101
嘗試連線資料庫
[root@localhost ~]# mysql --login-path=remote
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 181
Server version: 5.6.31-77.0-log Percona Server (GPL), Release 77.0, Revision 5c1061c
Copyright (c) 2009-2016 Percona LLC and/or its affiliates
Copyright (c) 2000, 2016, 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> select user();
+--------------------+
| user() |
+--------------------+
| ss7@192.168.56.101 |
+--------------------+
1 row in set (0.00 sec)
mysql> exit
Bye
透過--login-path選項連線root本地使用者
[root@localhost ~]# mysql --login-path=client
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 182
Server version: 5.6.31-77.0-log Percona Server (GPL), Release 77.0, Revision 5c1061c
Copyright (c) 2009-2016 Percona LLC and/or its affiliates
Copyright (c) 2000, 2016, 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> select user();
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2140100/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Windows 安裝並配置 MySQL 5.6WindowsMySql
- MySQL最優配置模板( 5.6&5.7轉)MySql
- Mysql安全配置MySql
- linux mysql5.6版本的安裝配置過程LinuxMySql
- CentOS 下 MySQL 5.6 基於 RPM 的下載、安裝、配置CentOSMySql
- MySQL 5.6的表壓縮MySql
- LEMP環境搭建及配置(三)安裝MySQL5.6MySql
- MySQL - 安裝時的安全配置MySql
- MySQL安全配置基線MySql
- 關於加強MYSQL安全的幾點建議MySql
- CentOS 安裝 mysql 5.6CentOSMySql
- MySQL:5.6 升級 5.7MySql
- Windows 安裝 MySQL 5.6WindowsMySql
- Jmeter 登入使用了 jsencrypt 加密密碼的登入介面JMeterJS加密密碼
- Mysql5.6 for Centos6.5原始碼編譯安裝MySqlCentOS原始碼編譯
- MySQL 5.6 GTID 原理以及使用MySql
- Linux安裝Mysql5.6LinuxMySql
- MySQL密碼安全MySql密碼
- 【Mysql】MySQL 5.6中如何定位DDL被阻塞的問題MySql
- MySQL 5.6建索引的正確姿勢MySql索引
- Mysql5.6 自動化部署MySql
- MySQL5.6 create table原理分析MySql
- MySQL 5.6大查詢和大事務監控指令碼(Python 2)MySql指令碼Python
- MySQL和PostgreSQL資料庫安全配置MySql資料庫
- Linux上yum安裝mysql5.6LinuxMySql
- MySQL 5.6對大表做歸檔MySql
- mysql5.6 mysqldump備份報錯MySql
- MySQL5.6 PERFORMANCE_SCHEMA 說明MySqlORM
- MySQL 5.6中如何定位DDL被阻塞的問題MySql
- MySQL 5.6修改REDO日誌的大小和個數MySql
- mysql5.6生成排序欄位MySql排序
- mysql 5.6效能監控表innodb_metricsMySql
- CentOS 6.7下yum方式安裝MySQL 5.6CentOSMySql
- MySQL 5.6 遭遇 OS bug INNODB MONITOR OUTPUT 事件MySql事件
- centos7 mysql5.6升級5.7CentOSMySql
- Mysql 5.6 Master和Slave 主備切換MySqlAST
- CentOS中MySQL5.6 資料庫主從(Master/Slave)同步安裝與配置詳解CentOSMySql資料庫AST
- Dotnet core結合jquery的前後端加密解密密碼密文傳輸的實現jQuery後端加密解密密碼
- MySQL 5.6, 5.7, 8.0版本的新特性彙總大全MySql