Изменить MySQL Timezone Windows - PullRequest
0 голосов
/ 04 мая 2018

Я пытаюсь изменить часовой пояс в 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' не распознано или представляет несколько часовых поясов.

UPD:

Я обнаружил странное поведение для моей установки:

Когда я изменил часовой пояс через Workbench, он создал новую папку в ProgramData.

Теперь он содержит две папки MySQL Server 5.5 и MySQL Server 5.7 . Возможно проблема с этим.

Ответы [ 2 ]

0 голосов
/ 06 февраля 2019

В Windows 10 я обнаружил, что могу сделать это, отредактировав "C: \ ProgramData \ MySQL \ MySQL Server 8.0 \ Data \ mysqld-auto.cnf".

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

Не забудьте перезапустить службу MYSQL80 после редактирования этого файла.

0 голосов
/ 08 мая 2018
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 |
+---------------------+
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...