重庆思庄Oracle、、PostgreSQL、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 39|回复: 0
打印 上一主题 下一主题

[安装] Mysql8.4配置ssl

[复制链接]
跳转到指定楼层
楼主
发表于 昨天 17:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 jiawang 于 2025-5-13 17:33 编辑

数据库服务器上
mkdir -p /etc/mysql/ssl
cd /etc/mysql/ssl
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout my-private.key -out my-cert.pem
chmod 400 my-private.key
chmod 444 my-cert.pem


[root@sztech ssl]# ll
total 8
-rw-r--r--. 1 root root 1220 Oct 15 17:08 my-cert.pem
-rw-r--r--. 1 root root 1704 Oct 15 17:08 my-private.key
[root@sztech ssl]#
服务端参数配置
My.cnf参数文件增加:
[mysqld]
tls_version = TLSv1.2,TLSv1.3
require_secure_transport=on
ssl-ca = /etc/mysql/ssl/my-cert.pem
ssl-cert = /etc/mysql/ssl/my-cert.pem
ssl-key = /etc/mysql/ssl/my-private.key

SSL用户的创建
Create user ‘wj'@'%' identified by ‘wj1234’;
grant all on *.* to 'wj'@'%' ;
ALTER USER ‘wj'@'%'  REQUIRE SSL;
FLUSH PRIVILEGES;

服务器上测试验证
不带ssl登录报错
[root@sztech ~]# mysql -uwj -pwj1234
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'wj'@'localhost' (using password: YES)

带ssl登录正常
[root@sztech ssl]#  mysql -uwj -pwj1234 --ssl_ca=/etc/mysql/ssl/my-cert.pem -h192.168.110.129
mysql: [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 11
Server version: 8.4.2 MySQL Community Server - GPL
Copyright (c) 2000, 2024, Oracle and/or its affiliates.


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> status
--------------
mysql  Ver 8.4.2 for Linux on x86_64 (MySQL Community Server - GPL)


Connection id:          11
Current database:
Current user:           wj@sztech
SSL:                    Cipher in use is TLS_AES_128_GCM_SHA256
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         8.4.2 MySQL Community Server - GPL
Protocol version:       10
Connection:             192.168.110.129 via TCP/IP
Server characterset:    utf8mb3
Db     characterset:    utf8mb3
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
TCP port:               3306
Binary data as:         Hexadecimal
Uptime:                 7 min 14 sec


Threads: 3  Questions: 21  Slow queries: 0  Opens: 119  Flush tables: 3  Open tables: 38  Queries per second avg: 0.048
--------------


mysql>


mysql> SHOW STATUS LIKE 'Ssl_cipher';
+---------------+------------------------+
| Variable_name | Value                  |
+---------------+------------------------+
| Ssl_cipher    | TLS_AES_128_GCM_SHA256 |
+---------------+------------------------+
1 row in set (0.00 sec)



分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2025-5-14 20:33 , Processed in 0.091575 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表