What is the method for mysql to modify the time zone?
This article introduces the relevant knowledge of "what is the method of mysql to modify the time zone". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Mysql method to modify the time zone: 1, in the mysql command line mode, the implementation of the "set global time_zone = 'time zone information'" command; 2, in the "my.cnf" file, find and change the value of the "default-time_zone" entry to the desired time zone.
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
Method 1: modify dynamically in mysql command line mode
1. View mysql's current time and current time zone
Select curtime (); # or select now ()
Show variables like 'time_zone%'; 2 rows in set (0.00 sec)
# time_zone indicates that mysql uses the time zone of system, while system_time_zone indicates that system uses CST time zone
2. Modify the time zone
Set global time_zone ='+ 8 set time_zone 00 hours; # # modify the global time zone of mysql to Beijing time, that is, our East 8 Zone flush privileges; ='+ 8 set time_zone 00 hours; # # modify the current session time zone effective immediately
Method 2: modify the time zone by modifying the my.cnf configuration file
Default-time_zone ='+ 8VR 00'
The modification is complete and restart the database server.
Method 3: with the help of PHP's mysql_connect () function (temporarily solve the time zone problem)
Mysql_query ("SET time_zone ='+ 8 00'")
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.
This is the end of the content of "what is the method for mysql to modify the time zone". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!