Showing posts with label RDS. Show all posts
Showing posts with label RDS. Show all posts

5/29/2015

Change timezone from UTC with RDS instance


Here is how to change timezone setting in your RDS instance

1, connect your RDS instance as root.
[user@ec2 ~]$ mysql -u root -p -h xxxxxx.yyyyyy.zzzzzz.rds.amazonaws.com

2. Change the timezone setting.
mysql> DELIMITER |
mysql> CREATE PROCEDURE mysql.`set_PST`()
    -> IF NOT (POSITION('rdsadmin@' IN CURRENT_USER()) = 1) THEN
    ->    SET SESSION time_zone = 'America/Los_Angeles';
    -> END IF |
mysql> DELIMITER ;

3. Create parameter group
find init_connect parameter and input 'CALL set_PST'. Then save changes.

4. Apply new parameter group to your RDS instance.

5. Log in to your RDS instance. Then submit the following command.

mysql> GRANT EXECUTE ON PROCEDURE mysql.set_PST TO 'username'@'hostname';


12/10/2014

How to create mysql user on Amazon RDS


When I created a new mysql user on RDS, I got the following error.

===
ERROR 1184 (08S01): Aborted connection  to db: 'unconnected' user:  host:  (init_connect command failed)
===
After googling a while, the cause looks that I changed the timezone of the RDS from UTC to JST.

I got around the issue by the following commands. I need to grant execute command to mysql DB to a new mysql user.


mysql> grant execute on mysql.* to 'some_user'@'%';
mysql> grant select on some_db.some_table to 'some_user'@"%";
mysql> flush privileges;
mysql> set password for 'some_user'@'%' = password('some_pass');

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| some_db            |
| mysql              |
+--------------------+
3 rows in set (0.00 sec)
Now it works, :) even though I don't like the new mysql user to access information schema and mysql db.