当前位置:网站首页>Three methods of modifying time zone in MySQL
Three methods of modifying time zone in MySQL
2022-06-30 18:07:00 【forever_ up422】
Summary record modification mysql Three ways to time zone .
Method 1 : adopt mysql Dynamic modification in command line mode
1.1 see mysql current time , Current time zone
> select curtime(); # or select now() It's fine too
+-----------+
| curtime() |
+-----------+
| 15:18:10 |
+-----------+
> show variables like "%time_zone%";
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| system_time_zone | CST |
| time_zone | SYSTEM |
+------------------+--------+
1.2 Change the time zone
> set global time_zone = '+8:00'; ## modify mysql The global time zone is Beijing time , That is where we are 8 District
> set time_zone = '+8:00'; ## Modify the current session time zone
> flush privileges; # Immediate effect
Method 2 : By modifying the my.cnf Configuration file to modify the time zone
# vim /etc/my.cnf ## stay [mysqld] Add... To the area
default-time_zone = '+8:00'
# /etc/init.d/mysqld restart ## restart mysql Make the new time zone effective
Method 3 : If it is not convenient to restart mysql, I want to solve the time zone problem temporarily , Can pass php Or other languages are initializing mysql Initializes mysql The time zone
here , With php For example , stay mysql_connect() Next use :
mysql_query("SET time_zone = '+8:00'")
边栏推荐
- Animesr: learnable degradation operator and new real world animation VSR dataset
- Spin lock exploration
- Solve the problem of unable to connect to command metric stream and related problems in the hystrix dashboard
- Importing alicloud ECS locally to solve deployment problems
- Write the simplest small program in C language Hello World
- Tubes响应性数据系统的设计与原理
- [sword finger offer] sword finger offer 53 - ii Missing numbers from 0 to n-1
- 6 张图带你搞懂 TCP 为什么是三次握手?
- Booking UI effect implemented by svg
- 基于eNSP的校园网设计的仿真模拟
猜你喜欢

巴比特 | 元宇宙每日必读:未成年人打赏后要求退款,虚拟主播称自己是大冤种,怎么看待这个监管漏洞?...

New skill: accelerate node through code cache JS startup

每日面试1题-如何防止CDN防护被绕过

What will be the game changes brought about by the meta universe?
![[零基础学IoT Pwn] 环境搭建](/img/3b/a0689a1570fcc40bb9a5a4e9cdc63c.png)
[零基础学IoT Pwn] 环境搭建

5G商用三年,未来创新何去何从?

Small Tools(3) 集成Knife4j3.0.3接口文档

Six pictures show you why TCP has three handshakes?

What did Tongji and Ali study in the CVPR 2022 best student thesis award? This is an interpretation of yizuo

Canvas cloud shape animation
随机推荐
Deep understanding of JVM (II) - memory structure (II)
Do fresh students get a job or choose a job after graduation?
A tough battle for Tencent cloud
Solve the problem of unable to connect to command metric stream and related problems in the hystrix dashboard
Redis (II) -- persistence
基於SSH的網上商城設計
Thinking on large file processing (upload, download)
Importing alicloud ECS locally to solve deployment problems
Deep understanding of JVM (V) - garbage collection (II)
.NET ORM框架HiSql实战-第一章-集成HiSql
TFTP下载kernel,nfs挂载文件系统
Network: principle and practice of server network card group technology
如何写一个技术方案
Distributed machine learning: model average Ma and elastic average easgd (pyspark)
Deep understanding of JVM (III) - memory structure (III)
DeFi借贷协议机制对比:Euler、Compound、Aave和Rari Capital
4 years of working experience, and you can't tell the five communication modes between multithreads. Can you believe it?
Canvas cloud shape animation
Elastic 8.0: opening a new era of speed, scale, relevance and simplicity
Analysis on the construction scheme and necessity of constructing expressway video monitoring platform