You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修改MySQL中的system_time_zone?已设置global.time_zone为+05:30但system_time_zone仍显示UTC

How to Change MySQL's @@system_time_zone to IST (+05:30)

Hey there! Let's clear up the confusion first: @@system_time_zone isn't a setting you can tweak directly via MySQL commands—it's pulled straight from your operating system's timezone. That's why your @@global.time_zone is correctly set to +05:30, but @@system_time_zone still shows UTC.

Here's how to fix it:

Step 1: Set Your Operating System's Timezone to IST

MySQL reads the system timezone only when it starts up, so you need to update your OS timezone first.

For Linux Systems:

  1. Check your current timezone status:
    timedatectl status
    
  2. Set the timezone to Indian Standard Time (IST maps to Asia/Kolkata):
    sudo timedatectl set-timezone Asia/Kolkata
    

For Windows Systems:

  1. Open Control Panel > Date and Time > Change time zone
  2. Select (UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi from the dropdown and save your changes.

Step 2: Restart MySQL Service

Since MySQL only fetches the system timezone on startup, you'll need to restart the service to apply the new setting:

Linux:

sudo systemctl restart mysql

Windows:

  1. Press Win + R, type services.msc and hit Enter to open the Services manager
  2. Locate the MySQL service, right-click it, and select Restart

Step 3: Verify the Change

Log back into MySQL and run the query again:

SELECT @@system_time_zone;

You should now see either IST or Asia/Kolkata (depending on your MySQL version)—both correspond to the +05:30 offset you want.

A Quick Side Note:

If you don't want to modify your OS timezone, rest easy: as long as @@global.time_zone is set to +05:30, MySQL will handle all date/time operations correctly using that timezone. @@system_time_zone is just a reflection of your OS's timezone and doesn't impact MySQL's internal time handling.

内容的提问来源于stack exchange,提问作者rk_py

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 15:17:39