5

I use mySQL on Mac OS. I login mySQL by the command

mysql - u root

then run the command below

select User from mysql.user;

It show the table below

+---------+
| User    |
+---------+
| root    |
| root    |
|         |
| root    |
|         |
| gerrit2 |
| root    |
+---------+
7 rows in set (0.08 sec)

I don't understand that there're 4 rows has root and 2 rows has no name. Please explain me. Thank you!

vietstone
  • 8,784
  • 16
  • 52
  • 79

2 Answers2

4

The row-defining part in mysql.users is the (host,user) tuple - this means:

  • You can have permissions without a username, depending on which host you connect from
  • You can have different permissions with the same username, again depending on the host
Eugen Rieck
  • 64,175
  • 10
  • 70
  • 92
2

You can have multiple records for the same user in the mysql.user table, since you can have different passwords and/or permissions depending on the host the user connects from. If you run select * you will see the differences.

Maxim Krizhanovsky
  • 26,265
  • 5
  • 59
  • 89