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
 

热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

通义千问
通义千问

阿里巴巴推出的全能AI助手

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
2026赚钱平台入口大全
2026赚钱平台入口大全

2026年最新赚钱平台入口汇总,涵盖任务众包、内容创作、电商运营、技能变现等多类正规渠道,助你轻松开启副业增收之路。阅读专题下面的文章了解更多详细内容。

21

2026.01.31

高干文在线阅读网站大全
高干文在线阅读网站大全

汇集热门1v1高干文免费阅读资源,涵盖都市言情、京味大院、军旅高干等经典题材,情节紧凑、人物鲜明。阅读专题下面的文章了解更多详细内容。

7

2026.01.31

无需付费的漫画app大全
无需付费的漫画app大全

想找真正免费又无套路的漫画App?本合集精选多款永久免费、资源丰富、无广告干扰的优质漫画应用,涵盖国漫、日漫、韩漫及经典老番,满足各类阅读需求。阅读专题下面的文章了解更多详细内容。

10

2026.01.31

漫画免费在线观看地址大全
漫画免费在线观看地址大全

想找免费又资源丰富的漫画网站?本合集精选2025-2026年热门平台,涵盖国漫、日漫、韩漫等多类型作品,支持高清流畅阅读与离线缓存。阅读专题下面的文章了解更多详细内容。

1

2026.01.31

漫画防走失登陆入口大全
漫画防走失登陆入口大全

2026最新漫画防走失登录入口合集,汇总多个稳定可用网址,助你畅享高清无广告漫画阅读体验。阅读专题下面的文章了解更多详细内容。

7

2026.01.31

php多线程怎么实现
php多线程怎么实现

PHP本身不支持原生多线程,但可通过扩展如pthreads、Swoole或结合多进程、协程等方式实现并发处理。阅读专题下面的文章了解更多详细内容。

1

2026.01.31

php如何运行环境
php如何运行环境

本合集详细介绍PHP运行环境的搭建与配置方法,涵盖Windows、Linux及Mac系统下的安装步骤、常见问题及解决方案。阅读专题下面的文章了解更多详细内容。

0

2026.01.31

php环境变量如何设置
php环境变量如何设置

本合集详细讲解PHP环境变量的设置方法,涵盖Windows、Linux及常见服务器环境配置技巧,助你快速掌握环境变量的正确配置。阅读专题下面的文章了解更多详细内容。

0

2026.01.31

php图片如何上传
php图片如何上传

本合集涵盖PHP图片上传的核心方法、安全处理及常见问题解决方案,适合初学者与进阶开发者。阅读专题下面的文章了解更多详细内容。

2

2026.01.31

热门下载

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

精品课程

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

共1课时 | 816人学习

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

共1课时 | 816人学习

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

共1课时 | 816人学习

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

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