Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to modify the mysql time zone

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Editor to share with you how to modify the mysql time zone, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!

The method to modify the mysql time zone: 1, to view the current time zone and time of MySQL; 2, to modify the time zone by modifying the parameters of environment variables or by modifying the my.cnf configuration file to modify the time zone.

This article operating environment: Windows7 system, Mysql5.7.14 version, Dell G3 computer.

Summary of the method of modifying time Zone by MySQL

Problem phenomenon:

The date in the database appears fine, but it is found that the time difference is 13 hours after the call through JSP. Upon inquiry, this problem is caused by the default time zone setting of MySQL.

The specific investigation and operation methods are as follows:

View the current time zone and time of MySQL

> show variables like "% time_zone%"; # View time zone

# time_zone indicates that mysql uses the time zone of system, while system_time_zone indicates that system uses CST time zone

> select curtime (); # View time > select now (); # View date + time

II. Modify the time zone

Method 1: modify the time zone by modifying the environment variable parameters

> set global time_zone ='+ 8 flush privileges; 00 hours; # # modify the global time zone of mysql to Beijing time, that is, our East 8 Zone > set time_zone ='+ 8 set time_zone 00 hours; # # modify the current session time zone > flush privileges; # effective immediately

In the actual operation, this modification is not successful, showing 0 row (s) affected

Method 2: modify the time zone by modifying the my.cnf configuration file

# vim / etc/my.cnf add: default-time_zone ='+ 8mysqld'to the [mysqld] area

After the modification is completed, you need to restart the startup MySQL, and the configuration takes effect.

The above is all the contents of the article "how to modify the mysql time zone". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report