MySQL驱动参数你知道多少呢?常见的几个大家应该都见过,如下:

| 
 参数  | 
 说明  | 
| 
 user  | 
 数据库用户名  | 
| 
 password  | 
 用户密码  | 
| 
 useUnicode  | 
 是否使用Unicode字符集,如果参数characterEncoding设置为gb2312或gbk,本参数值必须设置为true  | 
| 
 characterEncoding  | 
 当useUnicode设置为true时,指定字符编码。比如可设置为gb2312或gbk  | 
| 
 autoReconnect  | 
 当数据库连接异常中断时,是否自动重新连接。true为自动连接;false则相反。  | 
| 
 autoReconnectForPools  | 
 是否使用针对数据库连接池的重连策略  | 
| 
 failOverReadOnly  | 
 自动重连成功后,连接是否设置为只读  | 
| 
 maxReconnects  | 
 设置为true时,重试连接的次数3  | 
| 
 initialTimeout  | 
 设置为true时,两次重连之间的时间间隔,单位:秒  | 
| 
 connectTimeout  | 
 连接超时框时间(以毫秒为单位),0 表示没有超时。  | 
| 
 socketTimeout  | 
 网络套接字操作的超时时间,以毫秒为单位指定。值“0”表示没有超时。  | 
| 
 sslMode  | 
 默认情况下,网络连接是 SSL 加密的;此属性允许关闭安全连接,或选择不同的安全级别。  | 
| 
 connectionTimeZone  | 
 数据库连接时区  | 
| 
 rewriteBatchedStatements  | 
 重写SQL,以提高批量操作的性能  | 
| 
 logSlowQueries  | 
 是否启用慢查询日志  | 
| 
 slowQueryThresholdMillis  | 
 logSlowQueries为true的情况下,此参数用于配置慢查询的时间,大于 这个值就是慢查询  | 
以下是所有的属性配置,当我们生产环境中遇到问题的时候,就可以用这些参数来排查问题,以及进行一些调优。
| 
 属性名称  | 
 默认值  | 
 发布版本  | 
| 
 user  | 
 -  | 
 所有版本  | 
| 
 password  | 
 -  | 
 所有版本  | 
| 
 password1  | 
 -  | 
 8.0.28  | 
| 
 password2  | 
 -  | 
 8.0.28  | 
| 
 password3  | 
 -  | 
 8.0.28  | 
| 
 authenticationPlugins  | 
 -  | 
 5.1.19  | 
| 
 disabledAuthenticationPlugins  | 
 -  | 
 5.1.19  | 
| 
 ociConfigFile  | 
 -  | 
 8.0.27  | 
| 
 authenticationFidoCallbackHandler  | 
 -  | 
 8.0.29  | 
| 
 defaultAuthenticationPlugin  | 
 mysql_native_password  | 
 5.1.19  | 
| 
 ldapServerHostname  | 
 -  | 
 8.0.23  | 
| 
 属性名称  | 
 默认值  | 
 发布版本  | 
| 
 connectionAttributes  | 
 -  | 
 5.1.25  | 
| 
 connectionLifecycleInterceptors  | 
 -  | 
 5.1.4  | 
| 
 useConfigs  | 
 -  | 
 3.1.5  | 
| 
 clientInfoProvider  | 
 com.mysql.cj.jdbc.CommentClientInfoProvider  | 
 5.1.0  | 
| 
 createDatabaseIfNotExist  | 
 false  | 
 3.1.9  | 
| 
 databaseTerm  | 
 CATALOG  | 
 8.0.17  | 
| 
 detectCustomCollations  | 
 false  | 
 5.1.29  | 
| 
 disconnectOnExpiredPasswords  | 
 true  | 
 5.1.23  | 
| 
 interactiveClient  | 
 false  | 
 3.1.0  | 
| 
 passwordCharacterEncoding  | 
 -  | 
 5.1.7  | 
| 
 propertiesTransform  | 
 -  | 
 3.1.4  | 
| 
 rollbackOnPooledClose  | 
 true  | 
 3.0.15  | 
| 
 useAffectedRows  | 
 false  | 
 5.1.7  | 
| 
 属性名称  | 
 默认值  | 
 发布版本  | 
| 
 sessionVariables  | 
 -  | 
 3.1.8  | 
| 
 characterEncoding  | 
 -  | 
 1.1g  | 
| 
 characterSetResults  | 
 -  | 
 3.0.13  | 
| 
 connectionCollation  | 
 -  | 
 3.0.13  | 
| 
 customCharsetMapping  | 
 -  | 
 8.0.26  | 
| 
 trackSessionState  | 
 false  | 
 8.0.26  | 
| 
 属性名称  | 
 默认值  | 
 发布版本  | 
| 
 socksProxyHost  | 
 -  | 
 5.1.34  | 
| 
 socksProxyPort  | 
 1080  | 
 5.1.34  | 
| 
 socketFactory  | 
 com.mysql.cj.protocol.StandardSocketFactory  | 
 3.0.3  | 
| 
 connectTimeout  | 
 0  | 
 3.0.1  | 
| 
 socketTimeout  | 
 0  | 
 3.0.1  | 
| 
 dnsSrv  | 
 false  | 
 8.0.19  | 
| 
 localSocketAddress  | 
 -  | 
 5.0.5  | 
| 
 maxAllowedPacket  | 
 65535  | 
 5.1.8  | 
| 
 socksProxyRemoteDns  | 
 false  | 
 8.0.29  | 
| 
 tcpKeepAlive  | 
 true  | 
 5.0.7  | 
| 
 tcpNoDelay  | 
 true  | 
 5.0.7  | 
| 
 tcpRcvBuf  | 
 0  | 
 5.0.7  | 
| 
 tcpSndBuf  | 
 0  | 
 5.0.7  | 
| 
 tcpTrafficClass  | 
 0  | 
 5.0.7  | 
| 
 useCompression  | 
 false  | 
 3.0.17  | 
| 
 useUnbufferedInput  | 
 true  | 
 3.0.11  | 
| 
 属性名称  | 
 默认值  | 
 发布版本  | 
| 
 paranoid  | 
 false  | 
 3.0.1  | 
| 
 serverRSAPublicKeyFile  | 
 -  | 
 5.1.31  | 
| 
 allowPublicKeyRetrieval  | 
 false  | 
 5.1.31  | 
| 
 sslMode  | 
 PREFERRED  | 
 8.0.13  | 
| 
 trustCertificateKeyStoreUrl  | 
 -  | 
 5.1.0  | 
| 
 trustCertificateKeyStoreType  | 
 JKS  | 
 5.1.0  | 
| 
 trustCertificateKeyStorePassword  | 
 -  | 
 5.1.0  | 
| 
 fallbackToSystemTrustStore  | 
 true  | 
 8.0.22  | 
| 
 clientCertificateKeyStoreUrl  | 
 -  | 
 5.1.0  | 
| 
 clientCertificateKeyStoreType  | 
 JKS  | 
 5.1.0  | 
| 
 clientCertificateKeyStorePassword  | 
 -  | 
 5.1.0  | 
| 
 fallbackToSystemKeyStore  | 
 true  | 
 8.0.22  | 
| 
 tlsCiphersuites  | 
 -  | 
 5.1.35  | 
| 
 tlsVersions  | 
 -  | 
 8.0.8  | 
| 
 allowLoadLocalInfile  | 
 false  | 
 3.0.3  | 
| 
 allowLoadLocalInfileInPath  | 
 -  | 
 8.0.22  | 
| 
 allowMultiQueries  | 
 false  | 
 3.1.1  | 
| 
 allowUrlInLocalInfile  | 
 false  | 
 3.1.4  | 
| 
 requireSSL  | 
 false  | 
 3.1.0  | 
| 
 useSSL  | 
 true  | 
 3.0.2  | 
| 
 verifyServerCertificate  | 
 false  | 
 5.1.6  | 
| 
 属性名称  | 
 默认值  | 
 发布版本  | 
| 
 cacheDefaultTimeZone  | 
 true  | 
 8.0.20  | 
| 
 continueBatchOnError  | 
 true  | 
 3.0.3  | 
| 
 dontTrackOpenResources  | 
 false  | 
 3.1.7  | 
| 
 queryInterceptors  | 
 -  | 
 8.0.7  | 
| 
 queryTimeoutKillsConnection  | 
 false  | 
 5.1.9  | 
| 
 属性名称  | 
 默认值  | 
 发布版本  | 
| 
 allowNanAndInf  | 
 false  | 
 3.1.5  | 
| 
 autoClosePStmtStreams  | 
 false  | 
 3.1.12  | 
| 
 compensateOnDuplicateKeyUpdateCounts  | 
 false  | 
 5.1.7  | 
| 
 emulateUnsupportedPstmts  | 
 true  | 
 3.1.7  | 
| 
 generateSimpleParameterMetadata  | 
 false  | 
 5.0.5  | 
| 
 processEscapeCodesForPrepStmts  | 
 true  | 
 3.1.12  | 
| 
 useServerPrepStmts  | 
 false  | 
 3.1.0  | 
| 
 useStreamLengthsInPrepStmts  | 
 true  | 
 3.0.2  | 
| 
 属性名称  | 
 默认值  | 
 发布版本  | 
| 
 clobberStreamingResults  | 
 false  | 
 3.0.9  | 
| 
 emptyStringsConvertToZero  | 
 true  | 
 3.1.8  | 
| 
 holdResultsOpenOverStatementClose  | 
 false  | 
 3.1.7  | 
| 
 jdbcCompliantTruncation  | 
 true  | 
 3.1.2  | 
| 
 maxRows  | 
 -1  | 
 all versions  | 
| 
 netTimeoutForStreamingResults  | 
 600  | 
 5.1.0  | 
| 
 padCharsWithSpace  | 
 false  | 
 5.0.6  | 
| 
 populateInsertRowWithDefaultValues  | 
 false  | 
 5.0.5  | 
| 
 scrollTolerantForwardOnly  | 
 false  | 
 8.0.24  | 
| 
 strictUpdates  | 
 true  | 
 3.0.4  | 
| 
 tinyInt1isBit  | 
 true  | 
 3.0.16  | 
| 
 transformedBitIsBoolean  | 
 false  | 
 3.1.9  | 
| 
 属性名称  | 
 默认值  | 
 发布版本  | 
| 
 getProceduresReturnsFunctions  | 
 true  | 
 5.1.26  | 
| 
 noAccessToProcedureBodies  | 
 false  | 
 5.0.3  | 
| 
 nullDatabaseMeansCurrent  | 
 false  | 
 3.1.8  | 
| 
 useHostsInPrivileges  | 
 true  | 
 3.0.2  | 
| 
 useInformationSchema  | 
 false  | 
 5.0.0  | 
| 
 属性名称  | 
 默认值  | 
 发布版本  | 
| http://cdxtjz.cn/article/dpoishi.html |