View the current TIME zone of RDS

By default, AWS RDS takes UTC time. Our district is generally located in the 8th district, so our local time is UTC+8.

Connect to RDS and query the time zone of the current instance.

show variables where variable_name like 'time_zone';
Copy the code

The following output is displayed, indicating UTC of the current RDS time zone.

time_zone UTC

Adjust the RDS time zone

Time zone adjustment for RDS is done by adjusting parameter groups. AWS RDS does not allow you to modify the default parameter group. Therefore, check whether the parameter group used by the CURRENT RDS is the default parameter group. If it is the default parameter group, you need to create a parameter group. Then adjust the timeZone parameters on this parameter group, and then change the parameter group used by RDS to use the new parameter group.

Enter the parameter group menu on the left to create a parameter group. We usually adjust by copying a new set of parameters that we are currently using as a template. Select the group of parameters currently in use, Actions->Copy. For example, the current parameter group is PG-mysql57-demo, and the new parameter group is Pg-mysql57-demo-new.

Next, you can Modify the parameters of the new parameter group. Click Change parameter Group to enter the details page, search for the keyword time_zone, and then click Modify to Modify the parameters. From the optional values, you can find the desired value.

Enter the parameter group and search for time_zone. If the value is changed to Asia/Shanghai, the change is complete.

The parameter group increment is completed, the next step is to apply the parameter group to the corresponding instance. Go to the RDS to be adjusted and select a new parameter group in parameter group configuration. After confirming the modification, the system prompts you whether to apply the modification immediately. You can modify the Settings immediately or in the next maintenance window as required. Changing time_zone requires a restart of the database instance, which is selected in the next downtime window.

Select an appropriate time to restart the RDS.

Verifying the Modification takes effect

After the RDS restarts, run the preceding statement to query the time zone again. If the command output is Asia/Shanghai, the time zone is successfully changed.

show variables where variable_name like 'time_zone';
Copy the code

time_zone Asia/Shanghai


Happy Coding.