Modify the MySQL time zone, involving the time_zone Parameter

Source: Internet
Author: User

 

First, you need to view the current MySQL time zone, with the time_zone Parameter

 
Mysql> show variables like '% time_zone % '; + ------------------ + -------- + | variable_name | value | + ------------------ + -------- + | system_time_zone | CST | time_zone | system | + ------------------ + -------- + 2 rows in SET (0.00 Sec)

1 You can modify my. CNF
Add under [mysqld]
Default-time-zone = timezone
To modify the time zone. For example:
Default-time-zone = '+ 8:00'
After modification, remember to restart msyql.
Note that you must add it under [mysqld]. Otherwise, the unknown variable 'default-time-zone = + 8:00 'will appear'

2. You can also modify it online through the command line.

Set time_zone = timezone, for example, Beijing time (GMT + 0800) set time_zone = '+'; below: mysql> set time_zone = '+'; query OK, 0 rows affected (0.00 Sec) mysql> show variables like '% time_zone % '; + rows + -------- + | variable_name | value | + ---------------- + -------- + | system_time_zone | CST | time_zone | + 08:00 | + ---------------- + -------- + 2 rows in SET (0.00 Sec)

 

3. Use select now () to verify the time zone.

 mysql> show variables like '% time_zone % '; + ------------------ + -------- + | variable_name | value | + ------------------ + -------- + | system_time_zone | CST |  time_zone | + 08:00  | + ------------------ + -------- + 2 rows in SET (0.00 Sec) mysql> select now (); + ------------------- + | now () | + --------------------- + |  10:35:31  | + ------------------- + 1 row in SET (0.00 Sec) mysql>  set   time_zone = '+ 0: 00 ';  query OK, 0 rows affected (0.00 Sec) 
Mysql> show variables like '% time_zone %'; + ------------------ + -------- + | variable_name | value | + ------------------ + -------- + | system_time_zone | CST |Time_zone | + 00:00| + ------------------ + -------- + 2 rows in SET (0.00 Sec)
 
Mysql> select now (); + ------------------- + | now () | + --------------------- + |02:35:43| + --------------------- + 1 row in SET (0.00 Sec)

 

References:

Http://dev.mysql.com/doc/refman/5.7/en/time-zone-leap-seconds.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.