MySQL连接报错SSLException: Received fatal alert: protocol_version
可能的原因
-
MySQL 服务器端 SSL 协议配置:服务器端可能只支持特定版本的 SSL 协议,而客户端使用的协议版本与之不匹配。
-
客户端 SSL 协议配置:客户端代码或驱动程序可能默认使用了不被服务器支持的 SSL 协议版本。
-
安全策略更新:系统或 MySQL 版本的安全策略更新可能会限制某些 SSL 协议版本的使用。
-
解决方案
-
检查 MySQL 客户端的 SSL 配置
-
确保 MySQL 客户端也配置为使用 SSL/TLS。
-
如果使用的是 MySQL 客户端库(例如 Java 的 Connector/J),请确保它支持与服务器相同的 SSL/TLS 协议。
-
例如,在 Java 中,可以通过
enabledTLSProtocols
参数指定 TLS 版本:jdbc:mysql://hostname:3306/database?enabledTLSProtocols=TLSv1.2
-
Java 8 及更高版本默认支持 TLSv1.2 和 TLSv1.3。
修改 MySQL 服务器配置
-
如果服务器未配置为支持所需的 TLS 版本,可以在 MySQL 配置文件(
my.cnf
或my.ini
)中修改tls_version
变量:[mysqld] tls_version = TLSv1.2,TLSv1.3
-
修改后重启 MySQL 服务器。
禁用 SSL(如果不需要)
-
如果您的场景不需要 SSL/TLS,可以在客户端禁用 SSL,方法是在连接 URL 中添加
useSSL=false
:jdbc:mysql://hostname:3306/database?useSSL=false
-
注意: 在生产环境中不建议禁用 SSL,因为这会降低安全性。
配置主从报错:MySql Host is blocked because of many connection errors
环境:mysql8
错误:Host is blocked because of many connection errors; unblock with ‘mysqladmin flush-hosts’
原因:
同一个ip在短时间内产生太多(超过mysql数据库max_connection_errors的最大值)中断的数据库连接而导致的阻塞;
解决方法:
1、提高max_connection_errors数量:
(1)、临时解决(重启后恢复):修改max_connection_errors的数量为1000:
set global max_connect_errors=1000;
查看是否修改成功:
SHOW GLOBAL VARIABLES LIKE '%max_connect_errors%';
(2)、永久修复:修改my.ini中max_connection_errors=1000。重启服务永久生效
2、使用mysqladmin flush-hosts 命令清理一下hosts文件(临时应急处理);
mysqladmin flush-hosts -h iphost -P port -u root -prootpasswd;
备注:也可以mysql -uroot -prootpasswd 在数据库中执行命令:
flush hosts;
配置主从报错:Authentication plugin ‘caching_sha2_password’ reported error: Authentication requires secure connection.
原因是mysql 8为了提高安全性,默认使用caching_sha2_password作为密码加密方式
问题分析:加密的方式需要修改
方式一、修改加密方式
alter user 'replica'@'%' identified with mysql_native_password by '123456';
方式二:设置从库的change master 时加get_master_public_key=1参数
#1.从库执行
stop slave;
#2.清除从库配置:
reset slave all;
#3.重新配置主库信息
change master to master_host='192.168.1.160', master_user='replica', master_password='123456', master_log_file='mysql-bin.000002', master_log_pos=157, get_master_public_key=1;
#4.开始复制主库
start slave;
#5.查询从库状态:
show slave status\G;
Mysql 参数autoReconnect=true 解决8小时连接失效
https://blog.youkuaiyun.com/lihaiming_2008/article/details/84751827
java.sql.SQLException: Value '0000-00-00 ' can not be represented as java.sql.Timestamp
https://blog.youkuaiyun.com/lihaiming_2008/article/details/84749698
Could not open Hibernate Session for transaction; JDBC begin failed
https://blog.youkuaiyun.com/lihaiming_2008/article/details/84758634