首頁 >資料庫 >mysql教程 >Change MySQL Timezone on Amazon RDS_MySQL

Change MySQL Timezone on Amazon RDS_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原創
2016-06-01 13:12:301214瀏覽

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