Skip to content

Instantly share code, notes, and snippets.

@ratpik
Last active July 7, 2023 07:16
Show Gist options
  • Save ratpik/5d1382c7bac8c42cfb1413c4aa17dc75 to your computer and use it in GitHub Desktop.
Save ratpik/5d1382c7bac8c42cfb1413c4aa17dc75 to your computer and use it in GitHub Desktop.
AWS MySQL RDS create user and grant access
## View all users who can connect to this database
SELECT `user` FROM `mysql.user`;
## Create a new user in MySQL/AWS MySQL RDS
CREATE USER 'yourusername'@'%' IDENTIFIED BY 'yourpassword';
## List the operations that are permitted for this user
SHOW GRANTS FOR 'yourusername'@'%';
-> GRANT USAGE ON *.* TO 'yourusername'@'%' (Explanation - https://stackoverflow.com/questions/2126225/why-is-a-grant-usage-created-the-first-time-i-grant-a-user-privileges)
## Grant permissions to perform CRUD operations on that database
GRANT SELECT, INSERT, UPDATE, DELETE ON `your_db_name`.* TO 'yourusername'@'%';
## Grant for managing schema
GRANT
SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER,
SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT,
CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, LOAD FROM S3,
SELECT INTO S3, INVOKE LAMBDA, INVOKE SAGEMAKER, INVOKE COMPREHEND
ON `your_db_name`.* TO 'yourusername'@'%';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment