Wildfly 数据源未连接到 MySql 数据库
Wildfly datasource does not connect to MySql database
我是 Wildfly/JBoss 的新手,所以我不知道该怎么做,从昨天中午开始我就一直在解决这个问题。
我正在尝试使用 mysql-connector-java-8.0.20.jar 作为连接器,我的 Wildfly 版本是 wildfly-19.0.0.Final。
所以服务器上的部署似乎工作正常,但每当我尝试添加数据源并测试连接时,我都会收到此错误:
"WFLYJCA0040: failed to invoke operation: WFLYJCA0047: Connection is not valid"
日志/服务器抛出:
2020-06-19 12:47:04,231 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-7) WFLYJCA0001: Bound data source [java:jboss/datasources/MySqlDS]
2020-06-19 12:47:04,353 WARN [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (External Management Request Threads -- 1) IJ000604: Throwable while attempting to get a new connection: null: javax.resource.ResourceException: IJ031084: Unable to create connection
at org.jboss.ironjacamar.jdbcadapters@1.4.20.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:345)
at org.jboss.ironjacamar.jdbcadapters@1.4.20.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:352)
at org.jboss.ironjacamar.jdbcadapters@1.4.20.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:287)
at org.jboss.ironjacamar.impl@1.4.20.Final//org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.createConnectionEventListener(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:1326)
at org.jboss.ironjacamar.impl@1.4.20.Final//org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.getConnection(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:499)
at org.jboss.ironjacamar.impl@1.4.20.Final//org.jboss.jca.core.connectionmanager.pool.AbstractPool.internalTestConnection(AbstractPool.java:1067)
at org.jboss.ironjacamar.impl@1.4.20.Final//org.jboss.jca.core.connectionmanager.pool.strategy.OnePool.testConnection(OnePool.java:93)
at org.jboss.as.connector@19.0.0.Final//org.jboss.as.connector.subsystems.common.pool.PoolOperations$TestConnectionInPool.invokeCommandOn(PoolOperations.java:240)
at org.jboss.as.connector@19.0.0.Final//org.jboss.as.connector.subsystems.common.pool.PoolOperations.execute(PoolOperations.java:97)
at org.jboss.as.controller@11.0.0.Final//org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:999)
at org.jboss.as.controller@11.0.0.Final//org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:743)
at org.jboss.as.controller@11.0.0.Final//org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:467)
at org.jboss.as.controller@11.0.0.Final//org.jboss.as.controller.OperationContextImpl.executeOperation(OperationContextImpl.java:1413)
at org.jboss.as.controller@11.0.0.Final//org.jboss.as.controller.ModelControllerImpl.internalExecute(ModelControllerImpl.java:429)
at org.jboss.as.controller@11.0.0.Final//org.jboss.as.controller.ModelControllerImpl.lambda$execute(ModelControllerImpl.java:246)
at org.wildfly.security.elytron-private@1.11.2.Final//org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:289)
at org.wildfly.security.elytron-private@1.11.2.Final//org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:255)
at org.jboss.as.controller@11.0.0.Final//org.jboss.as.controller.ModelControllerImpl.execute(ModelControllerImpl.java:246)
at org.jboss.as.domain-http-interface@11.0.0.Final//org.jboss.as.domain.http.server.DomainApiHandler.handleRequest(DomainApiHandler.java:212)
at io.undertow.core@2.0.30.Final//io.undertow.server.handlers.encoding.EncodingHandler.handleRequest(EncodingHandler.java:72)
at org.jboss.as.domain-http-interface@11.0.0.Final//org.jboss.as.domain.http.server.DomainApiCheckHandler.handleRequest(DomainApiCheckHandler.java:93)
at org.jboss.as.domain-http-interface@11.0.0.Final//org.jboss.as.domain.http.server.security.ElytronIdentityHandler.lambda$handleRequest[=12=](ElytronIdentityHandler.java:62)
at org.wildfly.security.elytron-private@1.11.2.Final//org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:313)
at org.wildfly.security.elytron-private@1.11.2.Final//org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:270)
at org.jboss.as.controller@11.0.0.Final//org.jboss.as.controller.AccessAuditContext.doAs(AccessAuditContext.java:254)
at org.jboss.as.controller@11.0.0.Final//org.jboss.as.controller.AccessAuditContext.doAs(AccessAuditContext.java:225)
at org.jboss.as.domain-http-interface@11.0.0.Final//org.jboss.as.domain.http.server.security.ElytronIdentityHandler.handleRequest(ElytronIdentityHandler.java:61)
at io.undertow.core@2.0.30.Final//io.undertow.server.handlers.BlockingHandler.handleRequest(BlockingHandler.java:56)
at io.undertow.core@2.0.30.Final//io.undertow.server.Connectors.executeRootHandler(Connectors.java:376)
at io.undertow.core@2.0.30.Final//io.undertow.server.HttpServerExchange.run(HttpServerExchange.java:830)
at org.jboss.threads@2.3.3.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads@2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
at org.jboss.threads@2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads@2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:835)
at org.jboss.threads@2.3.3.Final//org.jboss.threads.JBossThread.run(JBossThread.java:485)
Caused by: java.sql.SQLException: The server time zone value 'Mitteleurop?ische Sommerzeit' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to use a more specifc time zone value if you want to utilize time zone support.
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
at org.jboss.ironjacamar.jdbcadapters@1.4.20.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:321)
... 35 more
Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'Mitteleurop?ische Sommerzeit' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to use a more specifc time zone value if you want to utilize time zone support.
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:132)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2120)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2143)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1310)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:967)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826)
... 39 more
2020-06-19 12:47:04,356 ERROR [org.jboss.as.controller.management-operation] (External Management Request Threads -- 1) WFLYCTL0013: Operation ("test-connection-in-pool") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "MySqlDS")
]) - failure description: "WFLYJCA0040: failed to invoke operation: WFLYJCA0047: Connection is not valid"
正如我所说,我是一个新手,所以请不要期望有太多关于 wildfly 的现有知识。
谢谢你的问候!
解决方案 1:使用连接器上的数据库 url 传递时区
您的数据库 url 应该类似于 jdbc:mysql://ip_address:port/port?serverTimezone=UTC
您可以更改为您选择的时区
解决方案 2:更改 MySQL 配置文件
在 ubuntu 上,配置文件是 my.cnf。对于 ubuntu 18.04,文件的位置是 /etc/mysql/my.cnf
添加一行如下:
默认时区 = '+01:00'
设置为您喜欢的时区
重新启动您的 MySQL 服务器。
是的,谢谢,解决方案 2 成功了!
在我的例子中,my.cnf-文件被称为“我的”,所以这有点令人困惑。不知道为什么叫这个名字
我在这个路径找到了文件:
C:\ProgramData\MySQL\MySQL 服务器 8.0
我是 Wildfly/JBoss 的新手,所以我不知道该怎么做,从昨天中午开始我就一直在解决这个问题。 我正在尝试使用 mysql-connector-java-8.0.20.jar 作为连接器,我的 Wildfly 版本是 wildfly-19.0.0.Final。 所以服务器上的部署似乎工作正常,但每当我尝试添加数据源并测试连接时,我都会收到此错误:
"WFLYJCA0040: failed to invoke operation: WFLYJCA0047: Connection is not valid"
日志/服务器抛出:
2020-06-19 12:47:04,231 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-7) WFLYJCA0001: Bound data source [java:jboss/datasources/MySqlDS]
2020-06-19 12:47:04,353 WARN [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (External Management Request Threads -- 1) IJ000604: Throwable while attempting to get a new connection: null: javax.resource.ResourceException: IJ031084: Unable to create connection
at org.jboss.ironjacamar.jdbcadapters@1.4.20.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:345)
at org.jboss.ironjacamar.jdbcadapters@1.4.20.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:352)
at org.jboss.ironjacamar.jdbcadapters@1.4.20.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:287)
at org.jboss.ironjacamar.impl@1.4.20.Final//org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.createConnectionEventListener(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:1326)
at org.jboss.ironjacamar.impl@1.4.20.Final//org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.getConnection(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:499)
at org.jboss.ironjacamar.impl@1.4.20.Final//org.jboss.jca.core.connectionmanager.pool.AbstractPool.internalTestConnection(AbstractPool.java:1067)
at org.jboss.ironjacamar.impl@1.4.20.Final//org.jboss.jca.core.connectionmanager.pool.strategy.OnePool.testConnection(OnePool.java:93)
at org.jboss.as.connector@19.0.0.Final//org.jboss.as.connector.subsystems.common.pool.PoolOperations$TestConnectionInPool.invokeCommandOn(PoolOperations.java:240)
at org.jboss.as.connector@19.0.0.Final//org.jboss.as.connector.subsystems.common.pool.PoolOperations.execute(PoolOperations.java:97)
at org.jboss.as.controller@11.0.0.Final//org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:999)
at org.jboss.as.controller@11.0.0.Final//org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:743)
at org.jboss.as.controller@11.0.0.Final//org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:467)
at org.jboss.as.controller@11.0.0.Final//org.jboss.as.controller.OperationContextImpl.executeOperation(OperationContextImpl.java:1413)
at org.jboss.as.controller@11.0.0.Final//org.jboss.as.controller.ModelControllerImpl.internalExecute(ModelControllerImpl.java:429)
at org.jboss.as.controller@11.0.0.Final//org.jboss.as.controller.ModelControllerImpl.lambda$execute(ModelControllerImpl.java:246)
at org.wildfly.security.elytron-private@1.11.2.Final//org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:289)
at org.wildfly.security.elytron-private@1.11.2.Final//org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:255)
at org.jboss.as.controller@11.0.0.Final//org.jboss.as.controller.ModelControllerImpl.execute(ModelControllerImpl.java:246)
at org.jboss.as.domain-http-interface@11.0.0.Final//org.jboss.as.domain.http.server.DomainApiHandler.handleRequest(DomainApiHandler.java:212)
at io.undertow.core@2.0.30.Final//io.undertow.server.handlers.encoding.EncodingHandler.handleRequest(EncodingHandler.java:72)
at org.jboss.as.domain-http-interface@11.0.0.Final//org.jboss.as.domain.http.server.DomainApiCheckHandler.handleRequest(DomainApiCheckHandler.java:93)
at org.jboss.as.domain-http-interface@11.0.0.Final//org.jboss.as.domain.http.server.security.ElytronIdentityHandler.lambda$handleRequest[=12=](ElytronIdentityHandler.java:62)
at org.wildfly.security.elytron-private@1.11.2.Final//org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:313)
at org.wildfly.security.elytron-private@1.11.2.Final//org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:270)
at org.jboss.as.controller@11.0.0.Final//org.jboss.as.controller.AccessAuditContext.doAs(AccessAuditContext.java:254)
at org.jboss.as.controller@11.0.0.Final//org.jboss.as.controller.AccessAuditContext.doAs(AccessAuditContext.java:225)
at org.jboss.as.domain-http-interface@11.0.0.Final//org.jboss.as.domain.http.server.security.ElytronIdentityHandler.handleRequest(ElytronIdentityHandler.java:61)
at io.undertow.core@2.0.30.Final//io.undertow.server.handlers.BlockingHandler.handleRequest(BlockingHandler.java:56)
at io.undertow.core@2.0.30.Final//io.undertow.server.Connectors.executeRootHandler(Connectors.java:376)
at io.undertow.core@2.0.30.Final//io.undertow.server.HttpServerExchange.run(HttpServerExchange.java:830)
at org.jboss.threads@2.3.3.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads@2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
at org.jboss.threads@2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads@2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:835)
at org.jboss.threads@2.3.3.Final//org.jboss.threads.JBossThread.run(JBossThread.java:485)
Caused by: java.sql.SQLException: The server time zone value 'Mitteleurop?ische Sommerzeit' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to use a more specifc time zone value if you want to utilize time zone support.
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
at org.jboss.ironjacamar.jdbcadapters@1.4.20.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:321)
... 35 more
Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'Mitteleurop?ische Sommerzeit' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to use a more specifc time zone value if you want to utilize time zone support.
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:132)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2120)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2143)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1310)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:967)
at deployment.mysql-connector-java-8.0.20.jar//com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826)
... 39 more
2020-06-19 12:47:04,356 ERROR [org.jboss.as.controller.management-operation] (External Management Request Threads -- 1) WFLYCTL0013: Operation ("test-connection-in-pool") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "MySqlDS")
]) - failure description: "WFLYJCA0040: failed to invoke operation: WFLYJCA0047: Connection is not valid"
正如我所说,我是一个新手,所以请不要期望有太多关于 wildfly 的现有知识。 谢谢你的问候!
解决方案 1:使用连接器上的数据库 url 传递时区
您的数据库 url 应该类似于 jdbc:mysql://ip_address:port/port?serverTimezone=UTC
您可以更改为您选择的时区
解决方案 2:更改 MySQL 配置文件
在 ubuntu 上,配置文件是 my.cnf。对于 ubuntu 18.04,文件的位置是 /etc/mysql/my.cnf
添加一行如下:
默认时区 = '+01:00'
设置为您喜欢的时区
重新启动您的 MySQL 服务器。
是的,谢谢,解决方案 2 成功了!
在我的例子中,my.cnf-文件被称为“我的”,所以这有点令人困惑。不知道为什么叫这个名字
我在这个路径找到了文件:
C:\ProgramData\MySQL\MySQL 服务器 8.0