mysql通过ssl的方式生成秘钥具体生成步骤

 更新时间:2013年06月09日 16:29:09   作者:  
在my.cnf末尾端设置ssl 参数, 然后重新启动mysql服务即可,通过openssl生成证书的配置, 在mysql db server上生成秘钥,具体步骤如下,感兴趣的朋友可以参考下哈
-- 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
4.3
openssl x509 -req -in client-req.pem -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > client-cert.pem
[root@mysql newcerts]# openssl x509 -req -in client-req.pem -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > client-cert.pem
Signature ok
subject=/C=ch/ST=shh/L=shh/O=ea/OU=db/CN=mysql.yest.nos/emailAddress=cm@xx.com
Getting CA Private Key

5
[]copy clent.* 3个文件到客户端机器上面/opt/mysql/ssl/去。

6 登陆验证
mysql -uxxx -pxxxx --ssl-ca=/opt/mysql/ssl/ca-cert.pem --ssl-cert=/opt/mysql/ssl/server-cert.pem --ssl-key=/opt/mysql/ssl/server-key.pem
conferce:http://www.docin.com/p-151590189.html

相关文章

  • MySQL GROUP BY多个字段的具体使用

    MySQL GROUP BY多个字段的具体使用

    在mysql中使用group by的意思是分组查询,如果group by后面跟的是多个字段,按照这些字段的不同组合分组查询,本文就详细的介绍MySQL GROUP BY多个字段的具体使用,感兴趣的可以了解一下
    2023-09-09
  • mysql滑动聚合/年初至今聚合原理与用法实例分析

    mysql滑动聚合/年初至今聚合原理与用法实例分析

    这篇文章主要介绍了mysql滑动聚合原理与用法,结合实例形式分析了mysql滑动聚合的相关功能、原理、使用方法及操作注意事项,需要的朋友可以参考下
    2019-12-12
  • MySQL单表千万级数据处理的思路分享

    MySQL单表千万级数据处理的思路分享

    日前笔者需要处理MySQL单表千万级的电子元器件数据,进行数据归类, 数据清洗以及器件参数处理,进而得出国产器件与国外器件的替换兼容性数据,为电子工程师寻找国产替换件提供参考。
    2021-06-06
  • 详解MySQL数据库--多表查询--内连接,外连接,子查询,相关子查询

    详解MySQL数据库--多表查询--内连接,外连接,子查询,相关子查询

    这篇文章主要介绍了MySQL多表查询,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2019-04-04
  • 优化MySQL数据库中的查询语句详解

    优化MySQL数据库中的查询语句详解

    这篇文章主要介绍了优化MySQL数据库中的查询语句,非常实用的经验总结,需要的朋友可以参考下
    2014-07-07
  • 如何修改mysql的隔离级别

    如何修改mysql的隔离级别

    MySQL的隔离级别是指数据库事务的隔离程度,用于控制并发事务之间的相互影响,本文就详细的介绍一下如何修改mysql的隔离级别,感兴趣的可以了解一下
    2023-08-08
  • MySQL控制流函数(-if ,elseif,else,case...when)

    MySQL控制流函数(-if ,elseif,else,case...when)

    这篇文章主要介绍了MySQL控制流函数(-if ,elseif,else,case...when),文章围绕主题展开详细的内容介绍,具有一定的参考价值,需要的朋友可以参考一下
    2022-07-07
  • 浅谈MySQL 亿级数据分页的优化

    浅谈MySQL 亿级数据分页的优化

    mysql大数据量使用limit分页,随着页码的增大,查询效率越低下。本文就来介绍一下MySQL 亿级数据分页的优化,感兴趣的小伙伴们可以参考一下
    2021-06-06
  • Win10环境下安装Mysql5.7.23问题及遇到的坑

    Win10环境下安装Mysql5.7.23问题及遇到的坑

    这篇文章主要介绍了Win10环境下安装Mysql5.7.23问题及遇到的坑,本文通过图文并茂的形式给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下
    2019-11-11
  • MySQL内部函数的超详细介绍

    MySQL内部函数的超详细介绍

    众所周知MySQL有很多内置的函数,下面这篇文章主要给大家介绍了关于MySQL内部函数的相关资料,文中通过实例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2022-08-08

最新评论