How to Create MySQL Users Accounts and Grant Privileges in MySQL 8.0 On Ubuntu Server 20.04

We will learn how to add new users to the MySQL database server. MySQL provides very flexible and granular user management options.

Follow these steps to add users to MySQL database server and assign access rights:

Step 1 : Open the MySQL shell with the following command.

Step 2 : From the MySQL shell, use the following command to add a new user to MySQL:

Step 3 : You can check the user account with the following command:

Step 4 : Next, add some privileges to this user account

Step 5 : Verify the privileges for the account as follows

Step 6 : Finally, exit the MySQL shell and try to log in with the new user account. You should log in successfully: