# vim /etc/my.cnf
###########################################
[mysqld]
require_secure_transport = ON
ssl-ca = /var/lib/mysql/ca.pem
ssl-cert = /var/lib/mysql/server-cert.pem
ssl-key = /var/lib/mysql/server-key.pem
############################################
# mysql -u root -p"MyS|QL@123"
mysql> ALTER USER 'root'@'%' REQUIRE SSL;
mysql> FLUSH PRIVILEGES;
mysql> exit
# systemctl restart mysqld
MySQL驱动
driverClassName=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://xx.xx.xx.xx:3306/test?allowMultiQueries=true&useUnicode&characterEncoding=UTF-8&autoReconnect=true&useSSL=true&verifyServerCertificate=false&requireSSL=true
username=root
password=MySQL@123
MariaDB驱动
driverClassName=org.mariadb.jdbc.Driver
url=jdbc:mariadb://xx.xx.xx.xx:3306/test?allowMultiQueries=true&useUnicode&characterEncoding=UTF-8&autoReconnect=true&useSSL=true&trustServerCertificate=true&requireSSL=true
username=root
password=MySQL@123
关于证书信任设置
MySQL: verifyServerCertificate=false
MariaDB: trustServerCertificate=true
How To Configure SSL/TLS for MySQL on CentOS7.x?
https://www.jianshu.com/p/d0bc851b9844
关于对MySQL开启SSL的理解
https://www.jianshu.com/p/4f5957c394db
MySQL的jdbc驱动 com.mysql.jdbc.Driver 和 com.mysql.cj.jdbc.Driver的区别
https://www.cnblogs.com/liaojie970/p/8916568.html
https://blog.csdn.net/superdangbo/article/details/78732700
MariaDB Connector/J
https://mariadb.com/kb/en/library/about-mariadb-connector-j
https://github.com/MariaDB/mariadb-connector-j/blob/master/documentation/use-mariadb-connector-j-driver.creole