Mariadb lock and unlock account

Mariadb lock and unlock account

Hello colleagues.

In today's short article, I want to tell you about how to lock and unlock MariaDB database users. We will carry out all actions on the ruslan@localhost account.

 

Article content:

  1. Check account lockout.
  2. Account blocking.
  3. Account unlock.

 

1. Check account lockout.

Before blocking or unblocking a user account, you need to check what status it currently has. There are two ways to check.

 

The first way to check the blocking of the user ruslan.

mariadb> SHOW CREATE USER 'ruslan'@'localhost';

mariadb_account_locking

The screenshot does not show any prerequisites that the account is blocked.

 

The second way to check is through the mysql.global_priv table.

mariadb> select user, Priv from mysql.global_priv where user = 'ruslan';

mariadb_account_locking

The screenshot shows the entry account_locked is false. This means that the account is not blocked.


 

2. Account blocking.

Now let's block the ruslan account. To do this, you need to use the command through editing user data.

mariadb> ALTER USER 'ruslan'@'localhost' ACCOUNT LOCK;

mariadb_account_locking

 

Now that we have blocked the user, he will no longer be able to log in to the database.

mariadb_account_locking

 

And now when we check back the status of the user, we will see a record that the ruslan account is blocked.

mariadb> SHOW CREATE USER 'ruslan'@'localhost';

mariadb> select user, Priv from mysql.global_priv where user = 'ruslan';

mariadb_account_locking


 

3. Account unlock.

To unlock the account, we will use the same ALTER USER command.

mariadb> ALTER USER 'ruslan'@'localhost' ACCOUNT UNLOCK;

mariadb_account_locking


 

Thank you all, I hope my article was of some help to you.

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