Solve the problem of eight hours time difference in MySQL insertion Generally, several parameters need to be added to the jdbc url. Most blogs give tutorials with these parameters: The configuration result is: To solve the time zone problem, I used serverTimezone=UTC in the past, but I ran into a small pit today and realized that this is not a panacea. First, insert a record normally It is found that the database record time is different from the local time The first method: Check the time in MySQL First use mysql -u username -p password in cmd to log in to mysql Enter Check MySQL time If the time is consistent with your local current time This means that there is no problem with MySQL time, but the problem lies with Java time. Try changing the jdbc url parameter to Second: If the query MySQL time is inconsistent with the local time, use the following statement to set the MySQL time zone show variables like '%time_zone%'; //Query the current time zone set global time_zone='+8:00'; //Add +8 hours to the standard time zone, i.e. Eastern Time Zone 8 flush privileges; # Take effect immediately Final test results success Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. You may also be interested in:
|
<<: Introduction and use of js observer mode
In tomcat, jsp is not garbled, but html Chinese i...
Table of contents 1. Overview 2. Digital Enumerat...
Table of contents 1. What is deconstruction? 2. A...
Table of contents Preface Laying the foundation p...
This article shares the specific code of js to ac...
Table of contents 1. Class 1.1 constructor() 1.2 ...
1. What is phantom reading? In a transaction, aft...
Flex Basic Concepts Flex layout (flex is the abbr...
In the process of Django web development, when wr...
[LeetCode] 178.Rank Scores Write a SQL query to r...
I recently discussed "advertising" with...
It is very convenient to connect to a remote serv...
1 Requirements Overview The data of multiple tabl...
Table of contents Exporting Docker containers Imp...
Table of contents Why optimize? ? Where to start?...