0x1 生成ssl的各种密钥:
mkdir -p /website/userdata/mysql-ca
cd /website/userdata/mysql-ca
# 服务端密钥
openssl genrsa 2048 > ca-key.pem
openssl req -sha1 -new -x509 -nodes -days 3650 -key ca-key.pem > ca-cert.pem
openssl req -sha1 -newkey rsa:2048 -days 730 -nodes -keyout server-key.pem > server-req.pem
openssl rsa -in server-key.pem -out server-key.pem
openssl x509 -sha1 -req -in server-req.pem -days 730 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > server-cert.pem
# 客户端密钥
openssl req -sha1 -newkey rsa:2048 -days 730 -nodes -keyout client-key.pem > client-req.pem
openssl rsa -in client-key.pem -out client-key.pem
openssl x509 -sha1 -req -in client-req.pem -days 730 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > client-cert.pem
0x2 修改mysql.cnf
[client]
# client节增加这些配置
ssl-ca=/website/userdata/mysql-ca/ca-cert.pem
ssl-cert=/website/userdata/mysql-ca/client-cert.pem
ssl-key=/website/userdata/mysql-ca/client-key.pem
[mysqld]
# mysqld节增加这些配置
ssl-cipher=DHE-RSA-AES256-SHA
ssl-ca=/website/userdata/mysql-ca/ca-cert.pem
ssl-cert=/website/userdata/mysql-ca/server-cert.pem
ssl-key=/website/userdata/mysql-ca/server-key.pem
0x3 重启mysqld服务
xdelve service.restart mysqld
0x4 给root用户ssl连接权限
# 在mysql客户端内操作
GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY * REQUIRE SSL;
flush PRIVILEGES;
0x5 navicat配置
下载client-cert.pem
,ca-cert.pem
,client-key.pem
这三个文件到本地电脑,编辑mysql连接配置
搞定
相关文档
暂无
随便看看
畅言模块加载中