首页 >数据库 >mysql教程 >Change MySQL Timezone on Amazon RDS_MySQL

Change MySQL Timezone on Amazon RDS_MySQL

WBOY
WBOY原创
2016-06-01 13:12:301182浏览

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 ;

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"

3.   Grant execute permission

GRANT EXECUTE ON PROCEDURE mysql.rds_store_time_zone TO 'user'@'%';
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn