This article was updated and rechecked on 25th of September 2022
Category: MariaDB Database
Added: 25th of September 2022
Updated On: 25th of September 2022
Viewed: 2,772 times
Related Tips & Tutorials
➔
Install MariaDB database in Ubuntu based distributions 2022 (Part 1)➔
Create a new database, table and insert data, using MariaDB in the Linux Terminal (Part 3)➔
Perform basic SELECT queries in MariaDB using the Linux Terminal (Part 4)
Create a new user using MariaDB database in the Linux Terminal (Part 2)
If you haven't installed MariaDB, please go back to Part 1 using the drop down menu above.

The next thing we need to do is create a new user. You can create as many users as you like, with each user being able to login to MariaDB and create new database(s).
If you have ever used CPanel to create a new database with a new user, this is the very same thing but using the terminal.
To create a new user in MariaDB, first we need to login to MariaDB as root.
mysql -u root -p
Now we need to create a new user. In the terminal enter the following command.
CREATE USER 'mycomputertips'@'localhost' IDENTIFIED BY '12345';
We have just created a new user named
mycomputertips with password
12345. You wouldn't use
12345 in real life, but for learning purposes we keep it simple.
If you want user
mycomputertips to be able to CREATE, UPDATE, DELETE and perform other database operations, we need to grant
mycomputertips all privileges.
In the terminal enter the following command
GRANT ALL PRIVILEGES ON * . * TO mycomputertips@localhost;
User
mycomputertips has now been granted all privileges.
To login as user
mycomputertips and create your first database enter the following command to exit MariaDB
exit
Then login as user
mycomputertips and when prompted enter your password
12345
mysql -u mycomputertips -p