0

0

MySQL通过SSL的方式生成秘钥

php中文网

php中文网

发布时间:2016-06-07 17:29:54

|

1595人浏览过

|

来源于php中文网

原创

-- mysql ssl 生成秘钥 1 check ssl是否已经开启 mysqlgt; show variables like

-- mysql ssl 生成秘钥
 

1 check ssl是否已经开启
 mysql> show variables like '%ssl%';
 +---------------+----------+
 | Variable_name | Value    |
 +---------------+----------+
 | have_openssl  | DISABLED |
 | have_ssl      | DISABLED |
 | ssl_ca        |          |
 | ssl_capath    |          |
 | ssl_cert      |          |
 | ssl_cipher    |          |
 | ssl_crl      |          |
 | ssl_crlpath  |          |
 | ssl_key      |          |
 +---------------+----------+
 9 rows in set (0.00 sec)
 
2 没有开启,所以打开
 在my.cnf末尾端设置ssl 参数, 然后重新启动mysql服务即可
 mysql> show variables like '%ssl%';
 +---------------+-------+
 | Variable_name | Value |
 +---------------+-------+
 | have_openssl  | YES  |
 | have_ssl      | YES  |
 | ssl_ca        |      |
 | ssl_capath    |      |
 | ssl_cert      |      |
 | ssl_cipher    |      |
 | ssl_crl      |      |
 | ssl_crlpath  |      |
 | ssl_key      |      |
 +---------------+-------+
 9 rows in set (0.00 sec)
 
3 通过openssl生成证书的配置, 在mysql db server上生成秘钥
 mkdir -p /etc/mysql/newcerts/
 cd /etc/mysql/newcerts/
 

3.1 openssl genrsa 2048 > ca-key.pem
 3.2 openssl req -new -x509 -nodes -days 1000 -key ca-key.pem > ca-cert.pem
 
[root@mysql newcerts]# openssl req -new -x509 -nodes -days 1000 -key ca-key.pem > ca-cert.pem
 You are about to be asked to enter information that will be incorporated
 into your certificate request.
 What you are about to enter is what is called a Distinguished Name or a DN.
 There are quite a few fields but you can leave some blank
 For some fields there will be a default value,
 If you enter '.', the field will be left blank.
 -----
 Country Name (2 letter code) [XX]:ch
 State or Province Name (full name) []:shh
 Locality Name (eg, city) [Default City]:shh
 Organization Name (eg, company) [Default Company Ltd]:xx
 Organizational Unit Name (eg, section) []:db
 Common Name (eg, your name or your server''s hostname) []:mysql.yest.nos
 Email Address []:xx@xx.com
 

3.3 openssl req -newkey  rsa:2048  -days 1000 -nodes -keyout server-key.pem > server-req.pem
 [root@mysql newcerts]# openssl req -newkey  rsa:2048  -days 1000 -nodes -keyout server-key.pem > server-req.pem
 Generating a 2048 bit RSA private key
 .......................................................................................................+++
 ..........................................................+++
 writing new private key to 'server-key.pem'
 -----
 You are about to be asked to enter information that will be incorporated
 into your certificate request.
 What you are about to enter is what is called a Distinguished Name or a DN.
 There are quite a few fields but you can leave some blank
 For some fields there will be a default value,
 If you enter '.', the field will be left blank.
 -----
 Country Name (2 letter code) [XX]:ch
 State or Province Name (full name) []:shh
 Locality Name (eg, city) [Default City]:ssh
 Organization Name (eg, company) [Default Company Ltd]:xx
 Organizational Unit Name (eg, section) []:db
 Common Name (eg, your name or your server''s hostname) []:mysql.yest.nos
 Email Address []:xx@xx.com
 
Please enter the following 'extra' attributes
 to be sent with your certificate request
 A challenge password []:820923
 An optional company name []:xx
 

4 在mysql db server客户端生成ssl文件
 4.1 openssl x509 -req -in server-req.pem -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > server-cert.pem
 
 [root@mysql newcerts]# openssl x509 -req -in server-req.pem -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > server-cert.pem
 Signature ok
 subject=/C=ch/ST=shh/L=ssh/O=ea/OU=db/CN=mysql.yest.nos/emailAddress=cm@xx.com
 Getting CA Private Key
 
4.2 openssl  req -newkey  rsa:2048  -days 1000 -nodes -keyout client-key.pem > client-req.pem
 
[root@mysql newcerts]# openssl  req -newkey  rsa:2048  -days 1000 -nodes -keyout client-key.pem > client-req.pem
 Generating a 2048 bit RSA private key
 .......+++
 ........................................................+++
 writing new private key to 'client-key.pem'
 -----
 You are about to be asked to enter information that will be incorporated
 into your certificate request.
 What you are about to enter is what is called a Distinguished Name or a DN.
 There are quite a few fields but you can leave some blank
 For some fields there will be a default value,
 If you enter '.', the field will be left blank.
 -----
 Country Name (2 letter code) [XX]:ch
 State or Province Name (full name) []:shh
 Locality Name (eg, city) [Default City]:shh
 Organization Name (eg, company) [Default Company Ltd]:xx
 Organizational Unit Name (eg, section) []:db
 Common Name (eg, your name or your server''s hostname) []:mysql.yest.nos
 Email Address []:cx@xx.com
 
Please enter the following 'extra' attributes
 to be sent with your certificate request
 A challenge password []:820923
 An optional company name []:xx
 

相关专题

更多
C++ 单元测试与代码质量保障
C++ 单元测试与代码质量保障

本专题系统讲解 C++ 在单元测试与代码质量保障方面的实战方法,包括测试驱动开发理念、Google Test/Google Mock 的使用、测试用例设计、边界条件验证、持续集成中的自动化测试流程,以及常见代码质量问题的发现与修复。通过工程化示例,帮助开发者建立 可测试、可维护、高质量的 C++ 项目体系。

8

2026.01.16

java数据库连接教程大全
java数据库连接教程大全

本专题整合了java数据库连接相关教程,阅读专题下面的文章了解更多详细内容。

29

2026.01.15

Java音频处理教程汇总
Java音频处理教程汇总

本专题整合了java音频处理教程大全,阅读专题下面的文章了解更多详细内容。

13

2026.01.15

windows查看wifi密码教程大全
windows查看wifi密码教程大全

本专题整合了windows查看wifi密码教程大全,阅读专题下面的文章了解更多详细内容。

42

2026.01.15

浏览器缓存清理方法汇总
浏览器缓存清理方法汇总

本专题整合了浏览器缓存清理教程汇总,阅读专题下面的文章了解更多详细内容。

6

2026.01.15

ps图片相关教程汇总
ps图片相关教程汇总

本专题整合了ps图片设置相关教程合集,阅读专题下面的文章了解更多详细内容。

9

2026.01.15

ppt一键生成相关合集
ppt一键生成相关合集

本专题整合了ppt一键生成相关教程汇总,阅读专题下面的的文章了解更多详细内容。

5

2026.01.15

php图片上传教程汇总
php图片上传教程汇总

本专题整合了php图片上传相关教程,阅读专题下面的文章了解更多详细教程。

2

2026.01.15

phpstorm相关教程大全
phpstorm相关教程大全

本专题整合了phpstorm相关教程汇总,阅读专题下面的文章了解更多详细内容。

4

2026.01.15

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
简单聊聊mysql8与网络通信
简单聊聊mysql8与网络通信

共1课时 | 793人学习

简单聊聊mysql8与网络通信
简单聊聊mysql8与网络通信

共1课时 | 793人学习

简单聊聊mysql8与网络通信
简单聊聊mysql8与网络通信

共1课时 | 793人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号