Home > Software design >  Drop user without a name from sql database
Drop user without a name from sql database

Time:12-15

Executing the following command

MariaDB [(none)]> select distinct user from mysql.user;

results in

 ------------- 
| User        |
 ------------- 
| app_user    |
|             |
| test_u      |
| mariadb.sys |
| root        |
 ------------- 
5 rows in set (0.001 sec)

So I have probably created a user with no name, correct? Perhaps by using a wrong syntax in the past. Question is how to drop the user? Something like the following doesn't seem to work:

MariaDB [(none)]> drop user ' ';
ERROR 1396 (HY000): Operation DROP USER failed for ' '@'%'

CodePudding user response:

drop is used to remove tables https://dev.mysql.com/doc/refman/8.0/en/drop-table.html, DROP TABLE User

Try DELETE FROM User WHERE User.user = ' '

CodePudding user response:

After some trial and error I stumbled upon mysql.user does not exist. During the execution of mysql_secure_installation the terminal states

By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.

Remove anonymous users? [Y/n] Y 
... Success!

So this ' ' user is equal to the anonymous user described here. Running select distinct user from mysql.user; after the removal of anonymous users.

Results in

 ------------- 
| User        |
 ------------- 
| app_user    |
| test_u      |
| mariadb.sys |
| root        |
 ------------- 

So probably this ' ' user was already there.

  • Related