Question

How to create a read only user for a managed DB

I want to create a user whom has only read access to Digital Ocean’s managed DB. How can I do that.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
August 22, 2024

Hey there!

You should be able to do that by following the official DigitalOcean documentation here:

For the read-only user, you would need to make sure that you only grant read-only privileges:

First, you’ll need to create the user in your MySQL database:

After that revoke all of the default privileges for that new readonly user:

REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'readonly'@'%';

Next, grant the necessary privileges for read-only access. The SELECT privilege is all you need to give them the ability to read from the database.

GRANT SELECT ON your_database.* TO 'read_only_user'@'%';

Replace 'read_only_user' with the username that you used in the previous step and also replace your_database with the name of the database you want the user to access.

To ensure that the new privileges take effect, run the following command:

FLUSH PRIVILEGES;

Happy coding! 🚀

- Bobby

KFSys
Site Moderator
Site Moderator badge
August 23, 2024

Heya,

I think you can follow these articles to achieve what you are looking for:

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.