Skip to content

Instantly share code, notes, and snippets.

@gauravbarthwal
Created February 2, 2015 07:50
Show Gist options
  • Save gauravbarthwal/6900211b088665e33cc9 to your computer and use it in GitHub Desktop.
Save gauravbarthwal/6900211b088665e33cc9 to your computer and use it in GitHub Desktop.
Amazon RDS timezone
In RDS to change Global timezone you have to be a super user. But unfortunately RDS doesn't give you super user's privileges. You can only change the session timezone but can't global. To solve this there are two approaches-
1- Your application should set the session timezone for RDS everytime whenever you are connecting with it.
Query- SET SESSION tine_zone = '+5:30';
2. Create a procedure in your mysql which does this thing for you everytime.
a.DELIMITER |
CREATE PROCEDURE mysql.store_time_zone ()
IF NOT (POSITION('rdsadmin@' IN CURRENT_USER()) = 1) THEN
SET SESSION time_zone = '+5:30';
END IF
|
DELIMITER ;
b. execute - GRANT EXECUTE ON PROCEDURE mysql.store_time_zone TO 'user'@'host';
c. Now login to your RDS.
d. Create Parameter Group. Search for "init_connect".
e. Edit the value of init_connect to "CALL mysql.store_time_zone". And save it.
f. Modify your RDS instance. In Parameter Group provide your parameter group's name. Rboot the RDS.
That's it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment