MySQL 驱动参数大全,以备不时之需

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的情况下,此参数用于配置慢查询的时间,大于 这个值就是慢查询

以下是所有的属性配置,当我们生产环境中遇到问题的时候,就可以用这些参数来排查问题,以及进行一些调优。

1 身份验证的属性

属性名称

默认值

发布版本

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

2 连接属性

属性名称

默认值

发布版本

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

3 Session 属性

属性名称

默认值

发布版本

sessionVariables

3.1.8

characterEncoding

1.1g

characterSetResults

3.0.13

connectionCollation

3.0.13

customCharsetMapping

8.0.26

trackSessionState

false

8.0.26

4 网络属性

属性名称

默认值

发布版本

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

5 安全属性

属性名称

默认值

发布版本

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

6 Statements 属性

属性名称

默认值

发布版本

cacheDefaultTimeZone

true

8.0.20

continueBatchOnError

true

3.0.3

dontTrackOpenResources

false

3.1.7

queryInterceptors

8.0.7

queryTimeoutKillsConnection

false

5.1.9

7 Prepared Statements 属性

属性名称

默认值

发布版本

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

8 Result Sets 属性

属性名称

默认值

发布版本

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

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

10 BLOB/CLOB 处理属性

属性名称

默认值

发布版本

autoDeserialize

false

3.1.5

blobSendChunkSize

1048576

3.1.9

blobsAreStrings

false

5.0.8

clobCharacterEncoding

5.0.0

emulateLocators

false

3.1.0

functionsNeverReturnBlobs

false

5.0.8

locatorFetchBufferSize

1048576

3.2.1

11 Datetime 类型处理属性

属性名称

默认值

发布版本

connectionTimeZone

3.0.2

forceConnectionTimeZoneToSession

false

8.0.23

noDatetimeStringSync

false

3.1.7

preserveInstants

true

8.0.23

sendFractionalSeconds

true

5.1.37

sendFractionalSecondsForTime

true

8.0.23

treatUtilDateAsTimestamp

true

5.0.5

yearIsDateType

true

3.1.9

zeroDateTimeBehavior

EXCEPTION

3.1.4

12 高可用性和集群属性

属性名称

默认值

发布版本

autoReconnect

false

1.1

autoReconnectForPools

false

3.1.3

failOverReadOnly

true

3.0.12

maxReconnects

3

1.1

reconnectAtTxEnd

false

3.0.10

retriesAllDown

120

5.1.6

initialTimeout

2

1.1

queriesBeforeRetrySource

50

3.0.2

secondsBeforeRetrySource

30

3.0.2

allowReplicaDownConnections

false

6.0.2

allowSourceDownConnections

false

5.1.27

ha.enableJMX

false

5.1.27

loadBalanceHostRemovalGracePeriod

15000

6.0.3

readFromSourceWhenNoReplicas

false

6.0.2

selfDestructOnPingMaxOperations

0

5.1.6

selfDestructOnPingSecondsLifetime

0

5.1.6

ha.loadBalanceStrategy

random

5.0.6

loadBalanceAutoCommitStatementRegex

5.1.15

loadBalanceAutoCommitStatementThreshold

0

5.1.15

loadBalanceBlocklistTimeout

0

5.1.0

loadBalanceConnectionGroup

5.1.13

loadBalanceExceptionChecker

com.mysql.cj.jdbc.ha.StandardLoadBalanceExceptionChecker

5.1.13

loadBalancePingTimeout

0

5.1.13

loadBalanceSQLExceptionSubclassFailover

5.1.13

loadBalanceSQLStateFailover

5.1.13

loadBalanceValidateConnectionOnSwapServer

false

5.1.13

pinGlobalTxToPhysicalConnection

false

5.0.1

replicationConnectionGroup

8.0.7

resourceId

5.0.1

serverAffinityOrder

8.0.8

13 性能扩展属性

属性名称

默认值

发布版本

callableStmtCacheSize

100

3.1.2

metadataCacheSize

50

3.1.1

useLocalSessionState

false

3.1.7

useLocalTransactionState

false

5.1.7

prepStmtCacheSize

25

3.0.10

prepStmtCacheSqlLimit

256

3.0.10

queryInfoCacheFactory

com.mysql.cj.PerConnectionLRUFactory

5.1.1

serverConfigCacheFactory

com.mysql.cj.util.PerVmServerConfigCacheFactory

5.1.1

alwaysSendSetIsolation

true

3.1.7

maintainTimeStats

true

3.1.9

useCursorFetch

false

5.0.0

cacheCallableStmts

false

3.1.2

cachePrepStmts

false

3.0.10

cacheResultSetMetadata

false

3.1.1

cacheServerConfiguration

false

3.1.5

defaultFetchSize

0

3.1.9

dontCheckOnDuplicateKeyUpdateInSQL

false

5.1.32

elideSetAutoCommits

false

3.1.3

enableEscapeProcessing

true

6.0.1

enableQueryTimeouts

true

5.0.6

largeRowSizeThreshold

2048

5.1.1

readOnlyPropagatesToServer

true

5.1.35

rewriteBatchedStatements

false

3.1.13

useReadAheadInput

true

3.1.5

14 调试/分析属性

属性名称

默认值

发布版本

logger

com.mysql.cj.log.StandardLogger

3.1.1

profilerEventHandler

com.mysql.cj.log.LoggingProfilerEventHandler

5.1.6

useNanosForElapsedTime

false

5.0.7

maxQuerySizeToLog

2048

3.1.3

maxByteArrayAsHex

1024

8.0.31

profileSQL

false

3.1.0

logSlowQueries

false

3.1.2

slowQueryThresholdMillis

2000

3.1.2

slowQueryThresholdNanos

0

5.0.7

autoSlowLog

true

5.1.4

explainSlowQueries

false

3.1.2

gatherPerfMetrics

false

3.1.2

reportMetricsIntervalMillis

30000

3.1.2

logXaCommands

false

5.0.5

traceProtocol

false

3.1.2

enablePacketDebug

false

3.1.3

packetDebugBufferSize

20

3.1.3

useUsageAdvisor

false

3.1.1

resultSetSizeThreshold

100

5.0.5

autoGenerateTestcaseScript

false

3.1.9

15 异常/警告属性

属性名称

默认值

发布版本

dumpQueriesOnException

false

3.1.3

exceptionInterceptors

5.1.8

ignoreNonTxTables

false

3.0.9

includeInnodbStatusInDeadlockExceptions

false

5.0.7

includeThreadDumpInDeadlockExceptions

false

5.1.15

includeThreadNamesAsStatementComment

false

5.1.15

useOnlyServerErrorMessages

true

3.0.15

16 集成其他产品的调优属性

属性名称

默认值

发布版本

overrideSupportsIntegrityEnhancementFacility

false

3.1.12

ultraDevHack

false

2.0.3

17 JDBC合规属性

属性名称

默认值

发布版本

useColumnNamesInFindColumn

false

5.1.7

pedantic

false

3.0.0

useOldAliasMetadataBehavior

false

5.0.4

18 X协议和X DevAPI属性

属性名称

默认值

发布版本

xdevapi.auth

PLAIN

8.0.8

xdevapi.compression

PREFERRED

8.0.20

xdevapi.compression-algorithms

zstd_stream,lz4_message,deflate_stream

8.0.22

xdevapi.compression-extensions

8.0.22

xdevapi.connect-timeout

10000

8.0.13

xdevapi.connection-attributes

8.0.16

xdevapi.dns-srv

false

8.0.19

xdevapi.fallback-to-system-keystore

true

8.0.22

xdevapi.fallback-to-system-truststore

true

8.0.22

xdevapi.ssl-keystore

8.0.22

xdevapi.ssl-keystore-password

8.0.22

xdevapi.ssl-keystore-type

JKS

8.0.22

xdevapi.ssl-mode

REQUIRED

8.0.7

xdevapi.ssl-truststore

6.0.6

xdevapi.ssl-truststore-password

6.0.6

xdevapi.ssl-truststore-type

JKS

6.0.6

xdevapi.tls-ciphersuites

8.0.19

xdevapi.tls-versions

8.0.19

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/233569.html<

(0)
运维的头像运维
上一篇2025-04-20 16:48
下一篇 2025-04-20 16:49

相关推荐

  • 个人主题怎么制作?

    制作个人主题是一个将个人风格、兴趣或专业领域转化为视觉化或结构化内容的过程,无论是用于个人博客、作品集、社交媒体账号还是品牌形象,核心都是围绕“个人特色”展开,以下从定位、内容规划、视觉设计、技术实现四个维度,详细拆解制作个人主题的完整流程,明确主题定位:找到个人特色的核心主题定位是所有工作的起点,需要先回答……

    2025-11-20
    0
  • 社群营销管理关键是什么?

    社群营销的核心在于通过建立有温度、有价值、有归属感的社群,实现用户留存、转化和品牌传播,其管理需贯穿“目标定位-内容运营-用户互动-数据驱动-风险控制”全流程,以下从五个维度展开详细说明:明确社群定位与目标社群管理的首要任务是精准定位,需明确社群的核心价值(如行业交流、产品使用指导、兴趣分享等)、目标用户画像……

    2025-11-20
    0
  • 香港公司网站备案需要什么材料?

    香港公司进行网站备案是一个涉及多部门协调、流程相对严谨的过程,尤其需兼顾中国内地与香港两地的监管要求,由于香港公司注册地与中国内地不同,其网站若主要服务内地用户或使用内地服务器,需根据服务器位置、网站内容性质等,选择对应的备案路径(如工信部ICP备案或公安备案),以下从备案主体资格、流程步骤、材料准备、注意事项……

    2025-11-20
    0
  • 如何企业上云推广

    企业上云已成为数字化转型的核心战略,但推广过程中需结合行业特性、企业痛点与市场需求,构建系统性、多维度的推广体系,以下从市场定位、策略设计、执行落地及效果优化四个维度,详细拆解企业上云推广的实践路径,精准定位:明确目标企业与核心价值企业上云并非“一刀切”的方案,需先锁定目标客户群体,提炼差异化价值主张,客户分层……

    2025-11-20
    0
  • PS设计搜索框的实用技巧有哪些?

    在PS中设计一个美观且功能性的搜索框需要结合创意构思、视觉设计和用户体验考量,以下从设计思路、制作步骤、细节优化及交互预览等方面详细说明,帮助打造符合需求的搜索框,设计前的规划明确使用场景:根据网站或APP的整体风格确定搜索框的调性,例如极简风适合细线条和纯色,科技感适合渐变和发光效果,电商类则可能需要突出搜索……

    2025-11-20
    0

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注