MariaDB how to create user - account

MariaDB how to create user - account

Colleagues hello to all.

In today's article, we'll talk about how you can create users in a MariaDB database. In MariaDB, you can create any number of users. Usernames should preferably contain only letters. In MariaDB, users are divided into local and external.

 

Article content:

  1. Creating a local user.
  2. Creating an external user.
  3. Request to show all database users.
  4. Good practice.

 

1. Creating a local user.

The local user is the user who can only connect to the database from the server itself, and will not be able to connect outside the server to the database.

Command to create a local user:

sql> CREATE USER 'inzhener'@'localhost' identified by 'Qwerty123';

mariadb_create_user


 

2. Creating an external user.

An external user is a user who will only be able to connect to the database outside the server, and will not be able to connect to the database locally.

Command to create an external user:

sql> CREATE USER 'inzhener'@'%' identified by 'Qwerty123';

mariadb_create_user


 

3. Query to show all database users.

Before creating any user, it is good practice to first look to see if there is a user with the same name. All users are stored in the mysql database in the  user table.

Request to show all database users:

sql> SELECT user, host FROM mysql.user;

mariadb_create_user

The mariadb.sys and mysql users are system users and I highly discourage you from doing anything with them. Don't touch them at all!


 

4. Good practice.

For example, you have a website that accesses a database directly, and of course it will use some kind of account to connect to. If you make a local account, then your site will not be able to connect to the database, and if you make an external account, then you will not be able to connect locally to the database, but the site can, and therefore it is better to create two accounts at once,  local and external with the same name.

sql> CREATE USER 'inzhener'@'localhost' identified by 'Qwerty123';

sql> CREATE USER 'inzhener'@'%' identified by 'Qwerty123';

mariadb_create_user


 

Thank you all, I hope that my article helped you in some way.

SIMILAR ARTICLES

MariaDB - ERROR Incorrect definition of table
MariaDB - ERROR Incorrect definition of table
MARIADB
Read more
Mariabackup backup - gzip compression
Mariabackup backup - gzip compression
MARIADB
Read more
Mariabackup error - Error writing file UNKNOWN errno 32 Broken pipe
Mariabackup error - Error writing file UNKNOWN errno 32 Broken pipe
MARIADB
Read more