更改mysql时区窗口

sczxawaw  于 2021-06-21  发布在  Mysql
关注(0)|答案(4)|浏览(342)

我尝试在my.ini中更改时区,但不起作用。
使用不同的变体:

default-time-zone = "Europe/Moscow"
default_time_zone = "Europe/Moscow"
default-time-zone = "+03:00"
and so on

但当我把它改成 SET GLOBAL time_zone = '+3:00'; 一切正常。
我想更改时区,因为我的rest api不起作用并抛出例外:
com.mysql.cj.core.exceptions.invalidconnectionattributeexception:服务器时区值“russia tz 2 standard time”无法识别或表示多个时区。
升级版本:
我发现我的安装有奇怪的行为:
当我通过workbench更改时区时,它会在programdata中创建新文件夹。
现在它包含两个文件夹mysql server5.5和mysql server5.7。可能有问题。

vlurs2pr

vlurs2pr1#

mysql提示:
选择@@global.time\u zone=“-4:00”
之后:
重新启动

bnl4lu3b

bnl4lu3b2#

Login to your server via SSH as the root user.
You can view MySQL's current time zone settings using the following command from the console:

mysql -e "SELECT @@global.time_zone;"
By default you should get back something similar to:

+--------------------+
| @@global.time_zone |
+--------------------+
| SYSTEM             |
+--------------------+
This is because by default your MySQL time zone will be set to the server's default SYSTEM time. If you're interested in changing the entire server's time zone this can be accomplished by setting the time zone in WHM.

You can see the server's SYSTEM time stamp using the following command:

date
Which will give back:

Mon Nov 26 12:50:07 EST 2012

You can see the current time stamp reported by the MySQL server using the following command:

mysql -e "SELECT NOW();"
This should give back the current time stamp:

+---------------------+
| NOW()               |
+---------------------+
| 2012-11-26 12:50:15 |
+---------------------+
Now you can edit your MySQL configuration file with your favorite text editor:

vi /etc/my.cnf
Then add the following line to change from EST (GMT -5:00) to CST (GMT -6:00):

default-time-zone = '-06:00'
Now save the /etc/my.cnf file with your new default.

To make the change active you'll want to restart the MySQL service with the following command:

service mysql restart

Now if you try to see the global time zone setting again with the command:

mysql -e "SELECT @@global.time_zone;"
You should now get back your new default:

+--------------------+
| @@global.time_zone |
+--------------------+
| -06:00             |
+--------------------+
You should also see now that the NOW() function has updated as well:

mysql -e "SELECT NOW();"
This should give back the current time stamp:

+---------------------+
| NOW()               |
+---------------------+
| 2012-11-26 11:50:15 |
+---------------------+
wfypjpf4

wfypjpf43#

通过将my.ini文件添加到安装文件夹并对其进行初始化,我的问题得以解决
也可以这样做:

SET GLOBAL time_zone = '+3:00';
dly7yett

dly7yett4#

在windows10上,我发现我可以通过编辑“c:\programdata\mysql\mysql server 8.0\data\mysqld auto.cnf”来做到这一点。

"mysql_server" : { "time_zone" : { "Value" : "SYSTEM" ...

别忘了在编辑完这个文件后重新启动mysql80服务。

相关问题