To remove remote anonymous users, you harden CLI access for MariaDB users by forcing the requirement for a username and password to get into the MariaDB shell. The process to do so is as follows.
| 1. Log in to MariaDB prompt and execute the command to enter the mysql schema. | MariaDB [none]> use mysql; |
| 2. Back up the user table to user_backup before changing it. | MariaDB [mysql]> create table user_backup as select * from user; |
| 3. Validate that the backup table was created and row count matches that of the mysql.db table. | MariaDB [mysql]> select count(*) from user_backup; |
| 4. List all users and hosts. | MariaDB [mysql]> select user,host from user; |
| 5. Remove anonymous/blank accounts. | MariaDB [mysql]> delete from user where user=""; |
| 6. Validate that the rows with blank user columns have been removed. | MariaDB [mysql]> select user,host from user; |