How to create a new user and manage permissions in MySQL?
Overview
In this tutorial, we will learn how to create and manage new and existing users using CLI (command line interface). These commands will function on any platform.
Prerequisites
There are certain prerequisites that need to be met before you begin:
An Ubuntu 20.04 server
MySQL installed on your Ubuntu system
Knowledge of CLI
Get Sarted
1. Follow these steps to setup a password-based access by creating an account to login:
2. Check access levels of existing accounts by using the below command:
3. To setup a password for root account, use the below command.
Or if you have an older version try:
4. Now, check the list of existing accounts to confirm.
5. Follow these steps for making a separate user access than root.
Or if you have a password setup, use:
6. Type this command to create a user.
Again, if you have an older version, try:
7. To grant suitable privileges to your user, type the following command:
8. Exit mysql.
Conclusion
In this tutorial, we have created a new user and granted privileges to the user in MySQL client. These commands will work on any operating system and let you manage the user in MySQL.
Last updated