MySQL involves the establishment of a distinct account with specific authentication credentials to access the database server. This process is typically carried out through the My SQL command-line interface or a graphical user interface. Using the CREATE USER statement, administrators define a new MySQL user by specifying a chosen username and assigning a corresponding password. Optionally, administrators can restrict the user’s access to specific hosts, such as ‘localhost’ for connections only from the local machine or ‘%’ for connections from any host.
Granting permissions in My SQL is a crucial aspect of database administration, allowing users specific levels of access to databases and their contents. Once a user is created, administrators use the GRANT statement to define the permissions associated with that user account. This statement specifies the type of actions a user can perform, such as SELECT for retrieving data, INSERT for adding new records, UPDATE for modifying existing data, and DELETE for removing records. The GRANT statement also designates the scope of access, indicating whether the permissions apply to a specific database, certain tables within a database, or even all databases on the MySQL server.

To create a new user and grant permissions in My SQL, you need to use the My SQL command-line interface (CLI) or a My SQL GUI tool.
Here’s a basic guide using the command-line interface:
Step 1: Access MySQL Command-Line
Open a terminal or command prompt and log in to My SQL using the following command. You will be prompted to enter the password for the My SQL root user.
mysql -u root -p
Step 2: Create a New MySQL User
To create a new My SQL user, use the following command:
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
Replace 'username' and 'password' with your desired username and password. The @'localhost' part restricts the user to connections from the local machine. If you want to allow connections from any host, you can use '%' instead of 'localhost'.

Step 3: Grant Permissions to the User
You need to grant specific privileges to the user. The following example grants all privileges on a specific database:

GRANT ALL PRIVILEGES ON your_database.* TO 'username'@'localhost';
Replace 'your_database' with the actual name of the database. If you want to grant all privileges on all databases, you can use the wildcard *:
GRANT ALL PRIVILEGES ON . TO 'username'@'localhost';
After granting privileges, you need to flush the privileges for the changes to take effect:
FLUSH PRIVILEGES;
Step 4: Exit MySQL Command-Line
Exit the My SQL command-line interface:
EXIT;

That’s it! You have created a new My SQL user and granted appropriate permissions. Ensure you replace placeholder values with your actual values, and remember to use strong and secure passwords for your users. Additionally, only grant the necessary permissions based on the requirements of your application.
The GRANT statement also designates the scope of access, indicating whether the permissions apply to a specific database, certain tables within a database, or even all databases on the MySQL server. Moreover, administrators can specify from which host or IP address the user is allowed to connect, enhancing security by restricting access to trusted sources. Once the permissions are granted, it is essential to execute the FLUSH PRIVILEGES command to ensure that the changes take effect immediately. Properly managing permissions is fundamental to database security, ensuring that users only have the necessary access required for their tasks, following the principle of least privilege and minimizing potential security risks.
Created user account initially has no privileges beyond the ability to log in. Additional steps, such as granting specific permissions using the GRANT statement, are typically taken to define the user’s access rights to databases, tables, and other server resources. This user creation process is fundamental to database security, ensuring that individuals or applications interact with the MySQL server using designated and secure authentication credentials.