Home > Database > Mysql Tutorial > Change MySQL Timezone on Amazon RDS_MySQL

Change MySQL Timezone on Amazon RDS_MySQL

WBOY
Release: 2016-06-01 13:12:30
Original
1186 people have browsed it

Amazon RDS doesn’t allow you to change timezone, It keeps same UTC time zone across all regions. time_zonevariable in the parameter group is read only.

You can change the time zone on each connection or session by making a procedure in default mysql database and call this function on each init connection.

1.    Create a procedure for IST

DELIMITER | CREATEPROCEDURE mysql.rds_store_time_zone ()IFNOT(POSITION('rdsadmin@'INCURRENT_USER())=1)THEN SET SESSION time_zone ='+5:30';ENDIF|DELIMITER ;
Copy after login

2.   Update parameter group

aws rds modify-db-parameter-group --db-parameter-group-name <em>parameter_group_name</em> --parameters "ParameterName=init_connect, ParameterValue=CALL mysql.rds_store_time_zone, ApplyMethod=immediate"
Copy after login

3.   Grant execute permission

GRANT EXECUTE ON PROCEDURE mysql.rds_store_time_zone TO 'user'@'%';
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template