CoderSathi
  • Tutorial
    • Java Tutorial
    • Swing Tutorial
    • JDBC Tutorial
    • Java String Tutorial
    • Servlet and JSP Tutorial
  • Mongo DB
  • AWS
  • DevOps
  • Linux
  • Git
Home > How to > Create User in MySQL

Create User in MySQL

Learn the concepts, implementation details, and practical steps with a clean developer-focused walkthrough.

Yuba Raj Kalathoki
By Yuba Raj Kalathoki
Last updated: July 1, 2026 · 1 min read · 0 Comments
Share: in X

In this post, we will learn to create user in MySQL server and also assign a role to specific database.

Make sure you have already logged in to your MySQL server with root credentials.

Create User

Syntax:

CREATE USER 'newUser'@'serverAddress' IDENTIFIED BY 'newPassword';

Let’s create a user called `myUser` with the password `myPass123`

Example:

CREATE USER 'myUser'@'localhost' IDENTIFIED BY 'myPass123';

Now, the user is created in the database.

Grant Permission

To give the specific permission to the user, we can follow the following syntax:

GRANT type_of_permission ON database_name.table_name TO ‘username’@'localhost’;

Let’s take a following scenario.

We have a database myDb and the user myUser should manage the database myDb then we can use following command:

GRANT ALL ON myDb.* TO ‘myUser’@'localhost’;

Related Posts:

  • MySQL Commands for Developers
  • How to Write User Stories and Acceptance Criteria: A…
  • Create an IAM user in AWS
  • User Defined Exception in Java
  • Assignment Operator in Java
  • Send Email Using Java
Tags:devopsmysql
Was this article helpful?
← Previous ArticleError Code: 1175. You are using safe update mode… while modifying MySQL data from Workbench
Next Article →Spring Boot Circular Dependency Error

Leave a Comment Cancel reply

You must be logged in to post a comment.

Recent Posts

  • How to implement Passwordless Authentication in Spring Boot: A Step-by-Step Guide
  • How to Use AWS CloudFront Signed URLs in Spring Boot?
  • How to Fix SSH Agent Forwarding on macOS: The Ultimate Guide for Developers
  • How to Read AWS Secrets Manager in Spring Boot (Step-by-Step)
  • How to Fix “Public Key Retrieval is not allowed” MySQL JDBC Error
CoderSathi

Your go-to resource for Java, Spring Boot, Microservices, AWS, and modern development tutorials.

Linkedin

Quick Links

  • About
  • Contact

Popular Topics

  • Java
  • Spring Boot
  • AWS
  • DevOps
  • MongoDB
  • Linux
  • Git
  • How to
© 2026 CoderSathi. All rights reserved. Privacy Policy · Sitemap