java - Skift MySQL Timezone Windows

Indlæg af Hanne Mølgaard Plasc

Problem



Jeg forsøger at ændre tidszone i my.ini , men det virker ikke.


Brug forskellige varianter:


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


Men når jeg ændrer det med SET GLOBAL time\_zone = '+3:00'; fungerer alt fint.


Jeg vil ændre tidszone, fordi min REST API ikke virker og slipper undtagelse:


com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: Serverens tidszoneværdi 'Russia TZ 2 Standard Time' er ikke genkendt eller repræsenterer mere end en tidszone.


UPD:


Jeg fandt mærkelig opførsel til min installation:


Da jeg blev ændret time\_zone via Workbench, oprettede den ny mappe i ProgramData.


Nu indeholder den to mapper MySQL Server 5.5 og MySQL Server 5.7 . Måske problem med det.

Bedste reference


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 |
+---------------------+