Sunday, December 1, 2019

GRANT ALL in Amazon RDS for MySQL

I was working on creating a user in MySQL database hosted on Amazon Relational Database Service (RDS) – AWS. Happen to run into an issue when granting privileges to the MySQL user, which was never an issue earlier. But that's okay, as long we have the fix.

mysql> CREATE USER 'sajid'@'%' IDENTIFIED BY 'sajid';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL ON *.* TO 'sajid'@'%';
ERROR 1045 (28000): Access denied for user 'sajid'@'%' (using password: YES)

But the above command works perfectly as expected, without any errors in on-premise servers. I have tried different ways, but the below fix works, rather than *.*. It has to be percent sign enclosed in the backquote as below.

mysql> GRANT ALL ON `%`.* TO sajid@`%`;
Query OK, 0 rows affected (0.00 sec)