vietstone
vietstone

Reputation: 9092

mysql.user table on mySQL

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!

Upvotes: 5

Views: 4854

Answers (2)

Eugen Rieck
Eugen Rieck

Reputation: 65332

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

Upvotes: 4

Maxim Krizhanovsky
Maxim Krizhanovsky

Reputation: 26739

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.

Upvotes: 2

Related Questions