VOOZH about

URL: https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql?comment=2949

โ‡ฑ How to Create a MySQL User and Grant Privileges (Step-by-Step) | DigitalOcean


How to Create a MySQL User and Grant Privileges (Step-by-Step)

Updated on January 23, 2026
๐Ÿ‘ How to Create a MySQL User and Grant Privileges (Step-by-Step)

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author(s)

Former Director of Community at DigitalOcean. Expert in cloud topics including LAMP Stack, CentOS, Ubuntu, MySQL, SSL certificates, and more.

๐Ÿ‘ Anish Singh Walia
Anish Singh Walia
Editor
Sr Technical Content Strategist and Team Lead
See author profile

I help Businesses scale with AI x SEO x (authentic) Content that revives traffic and keeps leads flowing | 3,000,000+ Average monthly readers on Medium | Sr Technical Writer(Team Lead) @ DigitalOcean | Ex-Cloud Consultant @ AMEX | Ex-Site Reliability Engineer(DevOps)@Nutanix

๐Ÿ‘ Vinayak Baranwal
Vinayak Baranwal
Editor
Technical Writer II
See author profile

Building future-ready infrastructure with Linux, Cloud, and DevOps. Full Stack Developer & System Administrator. Technical Writer @ DigitalOcean | GitHub Contributor | Passionate about Docker, PostgreSQL, and Open Source | Exploring NLP & AI-TensorFlow | Nailed over 50+ deployments across production environments.

Category:
Tags:

Still looking for an answer?

Was this helpful?

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!

You can grant multiple privileges in one command by separating them with commas: eg: โ€œGRANT UPDATE, SELECT ON [database name].[table name] TO โ€˜[username]โ€™@โ€˜localhostโ€™;โ€

This code from above has a backtick before localhost. It should be a single quote.

GRANT ALL PRIVILEGES ON * . * TO โ€˜newuserโ€™@โ€˜localhostโ€™;

Hi, nice intro. It was useful. I noticed that for the REVOKE command, one has to use FROM, not TO. Also, might be helpful for new users to know that they can use โ€˜%โ€™ as a wildcard instead of โ€˜localhostโ€™.

This worked for me. However to be able to use MySql Workbench it seems it wants another version of the user. I needed to do the following (which has taken me a few hours of playing around with to get right) mysql> select user,host from mysql.user; <โ€“to see users mysql> GRANT ALL ON . to user@โ€™%โ€™ IDENTIFIED BY โ€˜user-pwdโ€™; mysql> FLUSH PRIVILEGES; mysql> select user,host from mysql.user; mysql>quit Also need to comment out or change the bind-address to <droplet address>. This does reduce security. sudo nano /etc/mysql/my.cnf ;bind-address=127.0.0.1 exit and $service mysql start $service mysql stop

then get access on <droplet-ip> from my Sql workbench using user/user-pwd on std port for adminstering, creating and querying.

Thereโ€™s no link at the start of this tutorial to the first tutorial. Can you please add that link?

how to give permission to only select views in requried user pls send me urgent

@ravuri.srinivasarao7: Please read the second part of the article: โ€œHow To Grant Different User Permissionsโ€

Is there a way to just give permission to create a new table within the specified database, but not allow the creation of a new database?

๐Ÿ‘ Creative Commons
This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
  • Deploy on DigitalOcean

    Click below to sign up for DigitalOcean's virtual machines, Databases, and AIML products.

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 AI-native businesses

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.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

ยฉ 2026 DigitalOcean, LLC.Sitemap.
Dark mode is coming soon.