[root@vip soft]# mysql_ssl_rsa_setup --user=mysql --datadir=/usr/local/mysql/data Generating a 2048 bit RSA private key .......+++ ..+++ writing new private key to 'ca-key.pem' ----- Generating a 2048 bit RSA private key ......+++ ...................+++ writing new private key to 'server-key.pem' ----- Generating a 2048 bit RSA private key ..........................................+++ ............................+++ writing new private key to 'client-key.pem' -----
[root@vip soft]# ll /usr/local/mysql/data total 110668 -rw-rw----. 1 mysql mysql 56 Jan 21 22:00 auto.cnf -rw-------. 1 root root 1679 Jan 22 18:02 ca-key.pem -rw-r--r--. 1 root root 1107 Jan 22 18:02 ca.pem -rw-r--r--. 1 root root 1107 Jan 22 18:02 client-cert.pem -rw-------. 1 root root 1679 Jan 22 18:02 client-key.pem -rw-rw----. 1 mysql mysql 12582912 Jan 22 13:17 ibdata1 -rw-rw----. 1 mysql mysql 50331648 Jan 22 13:17 ib_logfile0 -rw-rw----. 1 mysql mysql 50331648 Jan 21 21:59 ib_logfile1 drwx------. 2 mysql mysql 4096 Jan 21 21:59 mysql drwx------. 2 mysql mysql 4096 Jan 21 21:59 performance_schema -rw-------. 1 root root 1679 Jan 22 18:02 private_key.pem -rw-r--r--. 1 root root 451 Jan 22 18:02 public_key.pem -rw-r--r--. 1 root root 1107 Jan 22 18:02 server-cert.pem -rw-------. 1 root root 1679 Jan 22 18:02 server-key.pem -rw-rw----. 1 mysql mysql 24939 Jan 22 13:17 vip.err -rw-rw----. 1 mysql mysql 5 Jan 22 13:17 vip.pid
[root@vip data]# ll *.pem -rw-------. 1 mysql mysql 1679 Jan 22 23:39 ca-key.pem -rw-r--r--. 1 mysql mysql 1107 Jan 22 23:39 ca.pem -rw-r--r--. 1 mysql mysql 1107 Jan 22 23:39 client-cert.pem -rw-------. 1 mysql mysql 1679 Jan 22 23:39 client-key.pem -rw-------. 1 mysql mysql 1679 Jan 22 23:39 private_key.pem -rw-r--r--. 1 mysql mysql 451 Jan 22 23:39 public_key.pem -rw-r--r--. 1 mysql mysql 1107 Jan 22 23:39 server-cert.pem -rw-------. 1 mysql mysql 1679 Jan 22 23:39 server-key.pem
[root@vip data]# mysql -uroot -proot Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 24 Server version: 5.6.39 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, 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> grant all on mydb.* to admin@'%' identified by 'admin' require ssl; Query OK, 0 rows affected (0.00 sec)
mysql> grant all on mydb.* to john@'%' identified by 'john' require x509; Query OK, 0 rows affected (0.00 sec)
3.Windows客户端SSL连接centos服务器端
require ssl登录
1 2 3
mysql -uadmin -padmin -h 192.168.1.133 --ssl-ca='C:\Program Files\Mysql\data\ca.pem' mysql -uadmin -padmin -h 192.168.1.133 --ssl-cert='C:\Program Files\Mysql\data\client-cert.pem' --ssl-key='C:\Program Files\Mysql\data\client-key.pem'
require x509登录:
温馨提示: SSL状态显示为Cipher in use is DHE-RSA-AES256-SHA,表示当前已经使用SSL连接。