mysql数据源url参数

it2026-01-03  10

jdbc:mysql://[host:port]/[database][?参数名1][=参数值1][&参数名2][=参数值2]…

参数名参数类型参数详解useUnicodeString是否使用Unicode字符集,如果参数characterEncoding设置为gb2312或gbk,本参数值必须设置为truecharacterEncodingString当useUnicode设置为true时,指定字符编码。比如可设置为utf-8autoReconnectboolean当数据库连接异常中断时,是否自动重新连接autoReconnectForPoolsboolean是否使用针对数据库连接池的重连策略maxReconnectsintautoReconnect设置为true时,重试连接的次数failOverReadOnlyboolean自动重连成功后,连接是否设置为只读serverTimezoneString设置数据库时区,UTC:为统一标准世界时间,比北京时间晚8小时; GMT%2B8:北京时间东八区;Asia/Shanghai:上海时间useSSLboolean是否进行SSL连接 高版本设置useSSL=true,不然会有警告信息allowMultiQueriesboolean允许批量更新,默认false,在批量更新时会报错verifyServerCertificateboolean设置SSL连接后是否验证服务器证书

记录问题:

连接数据库后报警告

WARN: Establishing SSL connection without server’s identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn’t set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to ‘false’. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification

解决:在URL中添加参数useSSL=true或useSSL=false

设置URL中添加参数useSSL=true后,连接不上数据库

解决:在useSSL=true后添加参数verifyServerCertificate=false useSSL=true&verifyServerCertificate=false

最新回复(0)