DevOps Blog - Nicolas Paris

Create ReadOnly and ReadWrite MySQL User

DevOps

Quick commande to create the Read-Only user and Read-Write user for MySQL. For security reasons, you should don't use you root user. You do automatisation of the process with terraform, but here is a quick way to get users up and running.

Read-Write User

CREATE USER 'myuser'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON mydatabase . * TO 'myuser'@'%';
FLUSH

Read-Only User

CREATE USER 'myuser_ro'@'%' IDENTIFIED BY 'password';
GRANT SELECT, SHOW VIEW ON mydatabase . * TO 'myuser_ro'@'%';
FLUSH