Post

Mysql User-Management

User Management Guide

Welcome to the User Management Guide! This tutorial will walk you through creating a new user and managing their permissions in MySQL. Let’s get started!

1. Create User

Step 1: Login to MySQL

Before creating a new user, login to your MySQL server as the root user:

1
mysql -u root -p

Step 2: Create User

To create a new user, use the following syntax:

Syntax

1
CREATE USER 'user_name'@'host_name' IDENTIFIED BY 'password';

Example

1
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'admin@123';

This command will create a user with the username inout and password Koha@inout.

2. Permissions

After creating a user, you need to assign the necessary permissions:

Step 1: Grant All Privileges

Use the following syntax to grant all privileges:

Syntax

1
GRANT ALL PRIVILEGES ON *.* TO 'user'@'host_name' WITH GRANT OPTION;

Example

1
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;

This will grant all superuser permissions to the user inout.

3. Refresh Privileges

After granting permissions, you need to refresh the privileges to apply the changes:

1
FLUSH PRIVILEGES;

This command refreshes the user privileges so that any changes made to the user accounts are applied to the system.


That’s it! You’ve successfully created a user and assigned the necessary permissions. If you have any questions or encounter any issues during this process, feel free to reach out for assistance. Happy managing!


This post is licensed under CC BY 4.0 by the author.