In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how mysql modifies time zone". In daily operation, I believe many people have doubts about how to modify time zone in mysql. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to modify time zone in mysql". Next, please follow the editor to study!
Mysql modify time zone methods: 1, through the mysql command line mode dynamic modification; 2, by modifying the my.cnf configuration file to modify the time zone; 3, through php or other languages to initialize the mysql time zone initialization.
This article operating environment: windows7 system, mysql8.0 version, Dell G3 computer.
How does mysql change the time zone?
Several methods of modifying time Zone in mysql
Description:
The following notes several ways to modify the mysql time zone.
Specific:
Method 1: modify dynamically in mysql command line mode
1.1 View mysql current time, current time zone
> select curtime (); # or select now () can also be +-+ | curtime () | +-+ | 15:18:10 | +-> show variables like "% time_zone%" +-+-+ | Variable_name | Value | +-+-+ | system_time_zone | CST | | time_zone | SYSTEM | +-+-+ 2 rows in set (0.00 sec) # Time_zone indicates that mysql uses the time zone of system System_time_zone indicates that system uses the CST time zone
1.2 modify the time zone
> 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
Method 2: modify the time zone by modifying the my.cnf configuration file
# vim / etc/my.cnf # # add default-time_zone ='+ 8 etc/init.d/mysqld restart # # to the [mysqld] area to restart mysql to make the new time zone effective
Method 3: if it is not convenient to restart mysql and you want to solve the time zone problem temporarily, you can initialize the mysql time zone when initializing mysql through php or other languages
Here, take php as an example, use mysql_query ("SET time_zone ='+ 8 mysql_query 00'") under mysql_connect ().
This changes the time zone without rebooting. However, some system functions of mysql still cannot be used, such as: now (). This sentence is still incomprehensible.
At this point, the study on "how to modify the time zone in mysql" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.