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.

KFSys
Site Moderator
Site Moderator badge
August 23, 2024

Heya,

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

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

Try DigitalOcean for free

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

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

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

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
Animation showing a Droplet being created in the DigitalOcean Cloud console