Create ReadOnly user in MySQL

Chetan Bothra
1 min readMar 10, 2021

--

Recently we got a requirement where we needed to created a RO only user for db. I know this is a common usecase. There are 1000s of blogs on this but I’m sharing the most easiest way of doing this.

Logging into MySQL Shell

mysql -u root -p #this is typical login mysql -h <hostname> -u <username> -p #this is when you have mysql on a remote location

this will prompty for password, please enter correct and you will be inside Mysql Shell

Create a new MySQL user account

CREATE USER 'ro'@'%' IDENTIFIED BY 'mysecretpassword';

the % in the command above means that user ro can be used to connect from any host. You can limit the access by defining the host from where the user can connect. Omitting this information will only allow the user to connect from the same machine.

Updating setting to make this effective

FLUSH PRIVILEGES;

We are all Done !

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Chetan Bothra
Chetan Bothra

Written by Chetan Bothra

AWS Certified | GCP | DevOps | SRE | Docker | DevSecOps | Kubernetes | Automation | Terraform | Serverless | Blockchain

No responses yet

Write a response