AWS RDS (Relational Database Service) is a fully-managed service that makes it easy to set up, operate, and scale a relational database in the cloud. Here’s how you can create a new MySQL user and grant permissions in AWS RDS:
- First, connect to the RDS instance using the MySQL command-line client. You can do this by running the command “mysql -h <hostname> -u <username> -p” and enter the password when prompted.
- Next, create a new MySQL user by running the following command:
CREATE USER '<username>'@'<hostname>' IDENTIFIED BY '<password>';
- Once the user is created, you can grant the user permission to access the database by running the following command:
GRANT <permission> ON <database>.* TO '<username>'@'<hostname>';
- To grant all permissions, use the command “GRANT ALL PRIVILEGES”, instead of <permission>
- You can also grant specific permissions such as SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER and etc.
- After granting the permissions, you need to flush the privileges by running the command “FLUSH PRIVILEGES”
- To revoke permissions, use the command “REVOKE <permission> ON <database>.* FROM ‘<username>’@'<hostname>’;”
It’s important to note that, you will need to replace the placeholders with the appropriate values for your RDS instance, such as the hostname, username, password, database, and permission.
Additionally, you can use the AWS RDS web interface to create and manage users and permissions.
It’s recommended to use the least privilege principle, which means that you should grant the minimum permissions required for the user to perform its intended tasks.