How to create read-only user in MySQL

Share this post to your friends !
  • 36
    Shares

SystemMen - This article will show you how to create read-only user in MySQL.

In which case do you need to use user read-only in MySQL? Normally in monitor systems, at the dashboard, you only need to use a read-only user.

This user will read data from the database and display information to the dashboards.

Commands to create a read-only user

You execute the following commands to create a user with SELECT permission in MySQL.

how-to-create-read-only-user-in-mysql How to create read-only user in MySQL
Create a read-only user in MySQL.

First, use the following command to create youruser user with the ip login is localhost.

CREATE USER 'youruser'@'localhost' IDENTIFIED BY 'yourpassword';

Next, use the following command to create youruser user with the ip login as your remote ip. For example, the remote ip is 192.168.100.10.

CREATE USER 'youruser'@'192.168.100.10' IDENTIFIED BY 'yourpassword';

Next, use the following command to grant SELECT permission (equivalent to read-only) to the user who just created your database.

GRANT SELECT ON yourdatabase . * TO 'youruser'@'localhost';
GRANT SELECT ON yourdatabase . * TO 'youruser'@'192.168.100.10';

And finally, you use the flush command in mysql to apply a new user.

FLUSH PRIVILEGES;

Conclusion

So you’ve created the read-only user in MySQL. The commands are quite simple but sometimes you won’t remember how to do it. Even I myself.

Hope it will be useful for you at some time.

If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.


Share this post to your friends !
  • 36
    Shares
If you appreciate what we share in this blog, you can support us by:
  1. Stay connected to: Facebook | Twitter | Google Plus | YouTube
  2. Subscribe email to recieve new posts from us: Sign up now.
  3. Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
  4. Become a Supporter - Make a contribution via PayPal.
  5. Support us by purchasing Ribbon Lite Child theme being using on this website.

We are thankful for your support.

«« »»

Got something to say? Join the discussion

Please keep in mind that all comments are subject to our Comment Policy. Your email address will not be published.
This site uses Akismet to reduce spam. Learn how your comment data is processed.