一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

Mysql|Sql Server|Oracle|Redis|MongoDB|PostgreSQL|Sqlite|DB2|mariadb|Access|數(shù)據(jù)庫技術(shù)|

服務(wù)器之家 - 數(shù)據(jù)庫 - Mysql - mysql配置SSL證書登錄的實現(xiàn)

mysql配置SSL證書登錄的實現(xiàn)

2021-09-28 14:17瀟雷 Mysql

應(yīng)國家等級保護三級安全要求,mysql 的 ssl 需要安全證書加密,本文主要介紹了mysql配置SSL證書登錄,感興趣的可以了解一下

前言

國家等級保護三級安全要求,mysql 的 ssl 需要安全證書加密,這里需要研究一下,選幾個賬戶演示下即可。mysql 的版本為 8.0.20

一、Mysql 啟用 SSL 配置

1.1 檢查是否開啟 ssl

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
mysql> show variables like '%ssl%';
+--------------------+-----------------+
| Variable_name      | Value           |
+--------------------+-----------------+
| have_openssl       | YES             | 
| have_ssl           | YES             |  # 已開啟ssl
| mysqlx_ssl_ca      |                 |
| mysqlx_ssl_capath  |                 |
| mysqlx_ssl_cert    |                 |
| mysqlx_ssl_cipher  |                 |
| mysqlx_ssl_crl     |                 |
| mysqlx_ssl_crlpath |                 |
| mysqlx_ssl_key     |                 |
| ssl_ca             | ca.pem          |
| ssl_capath         |                 |
| ssl_cert           | server-cert.pem |
| ssl_cipher         |                 |
| ssl_crl            |                 |
| ssl_crlpath        |                 |
| ssl_fips_mode      | OFF             |
| ssl_key            | server-key.pem  |
+--------------------+-----------------+
17 rows in set (0.56 sec)

1.2 設(shè)置用戶是否使用 SSL 連接

?
1
2
3
4
5
6
7
mysql> select ssl_type from user where user = 'dev_fqr' ;
+----------+
| ssl_type |
+----------+
|          |
+----------+
1 row in set (0.05 sec)

默認用戶是沒有使用 SSL 登錄的。
我們可以強制這個管理用戶使用 SSL 登錄。

?
1
2
3
alter user 'xxx'@'%' require ssl;
取消ssl驗證:
alter user 'xxx'@'%' require none;

更改后,該賬戶就無法登錄了,查看狀態(tài)變成下面這種

?
1
2
3
4
5
6
7
mysql> select ssl_type from user where user = 'dev_fqr' ;
+----------+
| ssl_type |
+----------+
| ANY      |
+----------+
1 row in set (0.01 sec)

測試登錄,本機無法直接登錄。

?
1
2
3
[root@localhost data]# mysql -u dev_fqr -p
Enter password:
ERROR 2026 (HY000): SSL connection error: SSL is required but the server doesn't support it

遠程客戶端無法直接登錄:

mysql配置SSL證書登錄的實現(xiàn)

1.3 使用 SSL 登錄

要想通過 SSL 登錄,就需要用到下面這幾個證書,通過 client 證書 與 server 端進行校驗通過才能登錄成功。

mysql配置SSL證書登錄的實現(xiàn)

1) 本機登錄

在 data 目錄下的三個文件證書登錄。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[root@localhost data]# mysql -udev_fqr -pDev@fqr2021 --ssl-ca=ca.pem --ssl-cert=client-cert.pem --ssl-key=client-key.pem
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 55
Server version: 8.0.22 MySQL Community Server - GPL
?
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
?
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.
?
You are enforcing ssl connection via unix socket. Please consider
switching ssl off as it does not make connection via unix socket
any more secure.
mysql>

2)navicate 遠程客戶端登錄

把這三個證書下載下來

mysql配置SSL證書登錄的實現(xiàn)

配置證書目錄,即可遠程訪問:

mysql配置SSL證書登錄的實現(xiàn)

二、總結(jié)

因為測評的時候不會看 JDBC 里面的配置,所以 JDBC 就不改了,不然要改動的地方非常的多,具體演示的時候可以用提前準備兩個賬號,到時候用客戶端連接即可。
目前兩臺 mysql 的ssl 用戶如下:

mysql配置SSL證書登錄的實現(xiàn)

到此這篇關(guān)于mysql配置SSL證書登錄的實現(xiàn)的文章就介紹到這了,更多相關(guān)mysql SSL證書登錄內(nèi)容請搜索服務(wù)器之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持服務(wù)器之家! 

原文鏈接:https://juejin.cn/post/7003228937635495972

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 精品国产在天天线在线麻豆 | 日本无遮挡吸乳视频看看 | 丰满大屁股美女一级毛片 | 亚洲午夜天堂 | 久久99精品国产自在自线 | 青柠影院在线观看免费完整版1 | 天堂欧美 | 韩日一区二区三区 | 亚洲人成在线观看一区二区 | 午夜熟女插插XX免费视频 | 小sao货水好多真紧h的视频 | 欧美s级人做人爱c视频 | 丝瓜污污视频 | 久草在在线免视频在线观看 | 色五月天天 | 国产成人影院 | 九九99靖品| 2020年最新国产精品视频免费 | 久久久这里有精品999 | 毛片段| 91大神大战高跟丝袜美女 | 色综合网天天综合色中文男男 | 男模chinesegayxxxx | 波多野结衣中文字幕乱七八糟 | 亚洲精品www久久久久久久软件 | 隔壁老王国产在线精品 | 亚洲精品久久7777777 | 91在线精品国产丝袜超清 | 高清视频大片免费观看 | 国产黄频在线观看高清免费 | 亚洲国产精品久久精品怡红院 | 91精品国产麻豆国产自产在线 | 国产在线看片网站 | 日本一区二区三区在线 观看网站 | 免费一级特黄特色大片在线 | 白鹿扒开内裤露出尿孔 | 天天天做天天天天爱天天想 | 国产精品久久久久久 | 天天狠天天透 | gay男强壮军人chinese | 国产精品青青在线观看香蕉 |