mysql insert time is 8 hours away from current time

Use mysql to insert time into the database, the time saved will automatically +8 hours, which is very uncomfortable.
Solution:
add in the configuration file:

&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

The complete url is:

url:
jdbc:mysql://ip:3306/数据库名?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

Adding the data is normal.
Welcome to leave a comment and learn together!!! Thanks!!!

===========================
Original article, reprinted with the source!

Guess you like

Origin blog.csdn.net/dayonglove2018/article/details/107060030