如果您的RDS MySQL執行個體的時區與您業務所在地區的時區不符,或者在夏令時和冬令時交替時需要校準執行個體的標準時間,可通過控制台或API介面修改執行個體的時區。本文介紹RDS MySQL執行個體時區的修改、驗證方法和時區與UTC位移量對照表。
應用情境
在以下情境下,您需要修改RDS MySQL執行個體的時區:
系統中RDS MySQL執行個體的時區與您業務所在地區的時區不符,例如,2021年5月30日之前購買的RDS MySQL執行個體的預設時區為SYSTEM,需要修改為您業務所在地區的時區。
美國、加拿大、澳大利亞、歐洲等國家在夏令時和冬令時交替時,需要您手動調整所使用的標準時間。例如,英國在由冬令時轉換為夏令時時,需要將冬令時時間(UTC)修改為夏令時時間(
UTC+1) 。
前提條件
注意事項
時區參數修改後,需要重啟執行個體才會生效。建議您在業務低峰期操作,並確保應用程式具有重連機制。
當MySQL的default_time_zone設為SYSTEM時可能存在以下風險:
主備時間不一致
高效能本地碟高可用執行個體可能因主備節點所在主機作業系統時區不同,造成MySQL主備時區不一致,極端情境下影響資料一致性。
執行個體效能下降
若業務中高頻使用
TIMESTAMP類型欄位,可能因時區轉換引發鎖競爭問題,導致執行個體效能波動。JDBC與MySQL對於CST時區解析不一致
CST時區存在多義性:MySQL預設解析為
UTC+08:00中國標準時間,而部分JDBC版本(如8.0.22/23)會解析為UTC - 6美國中部時間。當主機作業系統時區為CST時,可能會導致JDBC向MySQL讀取、寫入的資料不符合預期。典型案例:The time zone CST has different meanings on MySQL Server and on conntector/j。
在RDS控制台修改時區
訪問RDS執行個體列表,在上方選擇地區,然後單擊目標執行個體ID。
在左側導覽列中,單擊參數設定。
在可修改參數頁簽內找到
default_time_zone參數,單擊運行參數值,在彈出的對話方塊中修改時區的值。說明default_time_zone參數的取值含義,請參見時區與UTC位移量對照表。單擊提交參數,在彈出的對話方塊中,選擇生效的時間段,完成後單擊確定。
說明參數的修改未提交時,如果想取消修改,請單擊撤銷。
調用API介面修改時區
請求樣本
本樣本調用ModifyParameter介面將時區參數default_time_zone修改為+9:00。
...
// Parameter settings for API request
ModifyParameterRequest modifyParameterRequest = ModifyParameterRequest.builder()
.DBInstanceId("rm-bp1l94k5sw1zxxxxx")
.parameters("{"default_time_zone":"+9:00"}")
.forcerestart(true)
// Request-level configuration rewrite, can set Http request parameters, etc.
// .requestConfiguration(RequestConfiguration.create().setHttpHeaders(new HttpHeaders()))
.build();
...JSON格式返回結果
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId": "6D698793-FC2B-5FC1-A6DF-33EDAD1AD6AB"
}驗證時區修改結果
訪問RDS執行個體列表,在上方選擇地區,然後單擊目標執行個體ID。
在左側導覽列中,單擊參數設定。
在參數修改歷史頁簽內查看修改的時區參數值已生效。

時區與UTC位移量對照表
時區 | 標準時間位移 | 備忘 |
Afghanistan Standard Time | (UTC+04:30) | Kabul |
Alaskan Standard Time | (UTC-09:00) | Alaska |
Arabian Standard Time | (UTC+04:00) | Abu Dhabi, Muscat |
Atlantic Standard Time | (UTC-04:00) | Atlantic Time (Canada) |
AUS Central Standard Time | (UTC+09:30) | Darwin |
AUS Eastern Standard Time | (UTC+10:00) | Canberra, Melbourne, Sydney |
Belarus Standard Time | (UTC+03:00) | Minsk |
Canada Central Standard Time | (UTC-06:00) | Saskatchewan |
Cape Verde Standard Time | (UTC-01:00) | Cabo Verde Is. |
Cen. Australia Standard Time | (UTC+09:30) | Adelaide |
Central America Standard Time | (UTC-06:00) | Central America |
Central Asia Standard Time | (UTC+06:00) | Astana |
Central Brazilian Standard Time | (UTC-04:00) | Cuiaba |
Central Europe Standard Time | (UTC+01:00) | Belgrade, Bratislava, Budapest, Ljubljana, Prague |
Central European Standard Time | (UTC+01:00) | Sarajevo, Skopje, Warsaw, Zagreb |
Central Pacific Standard Time | (UTC+11:00) | Solomon Islands, New Caledonia |
Central Standard Time | (UTC-06:00) | Central Time (US and Canada) |
Central Standard Time (Mexico) | (UTC-06:00) | Guadalajara, Mexico City, Monterrey |
China Standard Time | (UTC+08:00) | Beijing, Chongqing, Hong Kong, Urumqi |
E. Africa Standard Time | (UTC+03:00) | Nairobi |
E. Australia Standard Time | (UTC+10:00) | Brisbane |
E. Europe Standard Time | (UTC+02:00) | Chisinau |
E. South America Standard Time | (UTC-03:00) | Brasilia |
Eastern Standard Time | (UTC-05:00) | Eastern Time (US and Canada) |
Georgian Standard Time | (UTC+04:00) | Tbilisi |
GMT Standard Time | (UTC) | Dublin, Edinburgh, Lisbon, London |
Greenland Standard Time | (UTC-03:00) | Greenland |
Greenwich Standard Time | (UTC) | Monrovia, Reykjavik |
GTB Standard Time | (UTC+02:00) | Athens, Bucharest |
Hawaiian Standard Time | (UTC-10:00) | Hawaii |
India Standard Time | (UTC+05:30) | Chennai, Kolkata, Mumbai, New Delhi |
Jordan Standard Time | (UTC+02:00) | Amman |
Korea Standard Time | (UTC+09:00) | Seoul |
Middle East Standard Time | (UTC+02:00) | Beirut |
Mountain Standard Time | (UTC-07:00) | Mountain Time (US and Canada) |
Mountain Standard Time (Mexico) | (UTC-07:00) | Chihuahua, La Paz, Mazatlan |
US Mountain Standard Time | (UTC-07:00) | Arizona |
New Zealand Standard Time | (UTC+12:00) | Auckland, Wellington |
Newfoundland Standard Time | (UTC-03:30) | Newfoundland |
Pacific SA Standard Time | (UTC-03:00) | Santiago |
Pacific Standard Time | (UTC-08:00) | Pacific Time (US and Canada) |
Pacific Standard Time (Mexico) | (UTC-08:00) | Baja California |
Russia Standard Time | (UTC+03:00) | Moscow, St. Petersburg, Volgograd |
SA Pacific Standard Time | (UTC-05:00) | Bogota, Lima, Quito, Rio Branco |
SE Asia Standard Time | (UTC+07:00) | Bangkok, Hanoi, Jakarta |
China Standard Time | (UTC+08:00) | Kuala Lumpur, Singapore |
Tokyo Standard Time | (UTC+09:00) | Osaka, Sapporo, Tokyo |
US Eastern Standard Time | (UTC-05:00) | Indiana (East) |
UTC | UTC | Coordinated Universal Time |
UTC-02 | (UTC-02:00) | Coordinated Universal Time-02 |
UTC-08 | (UTC-08:00) | Coordinated Universal Time-08 |
UTC-09 | (UTC-09:00) | Coordinated Universal Time-09 |
UTC-11 | (UTC-11:00) | Coordinated Universal Time-11 |
UTC+12 | (UTC+12:00) | Coordinated Universal Time+12 |
W. Australia Standard Time | (UTC+08:00) | Perth |
W. Central Africa Standard Time | (UTC+01:00) | West Central Africa |
W. Europe Standard Time | (UTC+01:00) | Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna |
Kathmandu Time | (UTC+5:45) | Kathmandu |
Myanmar Time | (UTC+6:30) | Rangoon, Nay Pyi Taw |
Uzbekistan Time | (UTC+5) | Lahore, Karachi, Islamabad |
Samoa Western Standard Time | (UTC+13) | Nuku Alofa, Appiah |
UTC-12 | (UTC-12) | Coordinated Universal Time-12 |
常見問題
相關API
通過API(ModifyParameter)修改default_time_zone取值。