(root@localhost) [(none)]> SHOW VARIABLES LIKE 'have_ssl'; +---------------+----------+ | Variable_name | Value | +---------------+----------+ | have_ssl | DISABLED | +---------------+----------+ 1 row in set (0.01 sec)
客户端 (win@192.168.154.190) [(none)]> SHOW STATUS LIKE 'ssl_cipher'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | Ssl_cipher | | +---------------+-------+ 1 row in set (0.00 sec)
(root@localhost) [(none)]> SHOW VARIABLES LIKE 'have_ssl'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | have_ssl | YES | +---------------+-------+ 1 row in set (0.00 sec)
查看当前是否是加密连接: (root@localhost) [(none)]> \s -------------- mysql Ver 14.14 Distrib 5.6.21, for Linux (x86_64) using EditLine wrapper
Connection id: 7 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 5.6.21-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial) Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: latin1 Db characterset: latin1 Client characterset: utf8 Conn. characterset: utf8 UNIX socket: /var/lib/mysql/mysql.sock Uptime: 30 sec
Threads: 5 Questions: 774 Slow queries: 0 Opens: 208 Flush tables: 1 Open tables: 201 Queries per second avg: 25.800 --------------
(root@localhost) [(none)]>
mysql Ver 14.14 Distrib 5.6.21, for Win64 (x86_64)
Connection id: 79 Current database: Current user: win@192.168.154.1 SSL: Cipher in use is DHE-RSA-AES256-SHA Using delimiter: ; Server version: 5.6.21-enterprise-commercial-advanced MySQL Enterprise S erver - Advanced Edition (Commercial) Protocol version: 10 Connection: 192.168.154.190 via TCP/IP Server characterset: latin1 Db characterset: latin1 Client characterset: gbk Conn. characterset: gbk TCP port: 3306 Uptime: 1 min 6 sec
Threads: 6 Questions: 1689 Slow queries: 0 Opens: 251 Flush tables: 1 Open tables: 244 Queries per second avg: 25.590 --------------
SSL: Cipher in use is DHE-RSA-AES256-SHA 这个就说明是加密连接。
在 my.cnf 下的 [mysqld] 下添加。重启服务器。 添加ssl用户: (root@localhost) [(none)]> grant all privileges on world.* to win@192.168.154.190 identified by '123' require ssl 这个用户必须用ssl 方式连接。 5、配置客户端 配置my.ini 在[mysql]下配置。 [mysql] ssl-ca=F:\mysql-advanced-5.6.21-winx64\cet\ca-cert.pem ssl-cert=F:\mysql-advanced-5.6.21-winx64\cet\client-cert.pem ssl-key=F:\mysql-advanced-5.6.21-winx64\cet\client-key.pem 配置好以后。 使用建立好的账户登录: 6、登录以后就可以看到。 mysql Ver 14.14 Distrib 5.6.21, for Win64 (x86_64)
Connection id: 1564 Current database: Current user: win@192.168.154.1 SSL: Cipher in use is DHE-RSA-AES256-SHA Using delimiter: ; Server version: 5.6.21-enterprise-commercial-advanced MySQL Enterprise S erver - Advanced Edition (Commercial) Protocol version: 10 Connection: 192.168.154.190 via TCP/IP Server characterset: latin1 Db characterset: latin1 Client characterset: gbk Conn. characterset: gbk TCP port: 3306 Uptime: 17 min 11 sec
Threads: 6 Questions: 40891 Slow queries: 0 Opens: 344 Flush tables: 1 Open tables: 337 Queries per second avg: 39.661 --------------