Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate users in mysql.user

Tags:

mysql

I just did a SELECT Host, User, Password FROM mysql.user; and I get the following results :

+-------------------------------------+----------+-------------------------------------------+
| Host                                | User     | Password                                  |
+-------------------------------------+----------+-------------------------------------------+
| localhost                           | root     | *CFB0F01E12976D94C46201145940E3EF71E32742 |
| my_name_goes_here-MacBook-Pro.local | root     | *CFB0F01E12976D94C46201145940E3EF71E32742 |
| 127.0.0.1                           | root     | *CFB0F01E12976D94C46201145940E3EF71E32742 |
| ::1                                 | root     | *CFB0F01E12976D94C46201145940E3EF71E32742 |
| localhost                           |          |                                           |
| my_name_goes_here-MacBook-Pro.local |          |                                           |
| %                                   | testuser | *00E247AC5F9AF26AE0194B41E1E769DEE1429A29 |
+-------------------------------------+----------+-------------------------------------------+

How do I remove these duplicate entries? (I can also see the previous version of mysql(5.5.8) in my hard drive)

like image 862
skiabox Avatar asked Aug 06 '11 08:08

skiabox


1 Answers

There are no duplicate entries. There is one row for each Host/User combination. But if you do need to remove one, have a look at DROP USER

Addition to answer

This query will show you that the empty users actually have a '' name:

SELECT Host, User, Password FROM mysql.user WHERE User LIKE '';

This means they can be removed with:

DROP USER ''@'localhost';
DROP USER ''@'my_name_goes_here-MacBook-Pro.local';

Do make sure you really want to remove them though. Maybe there are some processes that need them to be there and connect using these different hostnames.

like image 154
joostschouten Avatar answered Sep 17 '22 00:09

joostschouten