Mysql.user table in mySQL

I am using mySQL on Mac OS. I log in to mySQL using the command

mysql - u root

then run the command below

select a user from mysql.user;

It shows the table below

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

I do not understand that there are 4 lines with a root, and 2 lines do not have a name. Please explain me. Thanks!

+4
source share
2 answers

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

  • You may have permissions without a username, depending on which host you are connecting from
  • You may have different permissions with the same username, again depending on the host
+3
source

In the mysql.user table, you can have multiple entries for the same user, since you can have different passwords and / or permissions depending on which host the user is connecting from. If you run select *, you will see the differences.

+1
source

Source: https://habr.com/ru/post/1396407/


All Articles