How to Create a User in MariaDB on Ubuntu 22.04
In our last post, we elaborated on the procedure of listing databases in MariaDB on Ubuntu 22.04. Today’s post will demonstrate the method of creating a user in MariaDB.
Creating a user in MariaDB on Ubuntu involves setting up a new account that can be used to access and manage the MariaDB database server. Once the new user account is created, you can use it to log in to the MariaDB server and perform operations like querying data, creating tables, and updating data. To ensure the database’s security and integrity, only grant the user account the appropriate privileges.
In this post, we will have a look at the procedure of creating a user in MariaDB on Ubuntu 22.04.
Creating a User in MariaDB on Ubuntu 22.04
Creating a user in MariaDB provides controlled access to the database for different users based on their roles and responsibilities. This enhances security, administration, and accountability. Users can be granted specific permissions and their activity can be monitored, which helps prevent unauthorized access, manage the database more efficiently, and maintain compliance with regulatory requirements.
In this part, we will particularly discuss the method of creating a user in MariaDB on Ubuntu 22.04.
Step 1: Open the terminal
Press “CTRL+ALT+T” to launch the terminal:
Step 2: Open MariaDB Shell
To open the MariaDB shell, write the following command in the terminal:
sudo mysql -u root -p
Step 3: Create a User
Type the command below in the terminal, to create a user “sharqa” with the password “[email protected]” in MariaDB:
CREATE USER 'sharqa'@'localhost' IDENTIFIED BY '[email protected]';
Step 4: Grant all Privileges to Created User
Utilize the mentioned command to grant all privileges on all databases and tables to a MySQL user named “sharqa”:
GRANT ALL PRIVILEGES ON *.* TO 'sharqa'@'localhost';
Step 5: Flush Privileges
For making the changes take effect, execute the mentioned command:
Step 6: Exit MariaDB Shell
You can exit the MariaDB shell, once you are done with all operations:
That was all about creating a user in MariaDB on Ubuntu 22.04.
To create a user in MariaDB on Ubuntu 22.04, you have to open the Ubuntu terminal first. After that, execute the “sudo mysql -u root -p” command to open the MariaDB shell. Then, utilize the “CREATE USER ‘sharqa’@’localhost’ IDENTIFIED BY ‘[email protected]’;” command for creating the user. Grant all privileges to the created user by using the “GRANT ALL PRIVILEGES ON *.* TO ‘sharqa’@’localhost’;” command. At last, Flush privileges to make changes take effect. That’s how you can create a user in MariaDB on Ubuntu 22.04.