简体   繁体   English

mySQL上的mysql.user表

[英]mysql.user table on mySQL

I use mySQL on Mac OS. 我在Mac OS上使用mySQL。 I login mySQL by the command 我通过命令登录mySQL

mysql - u root mysql - 你的根

then run the command below 然后运行以下命令

select User from mysql.user; 从mysql.user中选择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. 我不明白有4行有root,2行没有名字。 Please explain me. 请解释一下。 Thank you! 谢谢!

The row-defining part in mysql.users is the (host,user) tuple - this means: mysql.users中的行定义部分是(主机,用户)元组 - 这意味着:

  • 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 您可以使用相同的用户名拥有不同的权限,具体取决于主机

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. 您可以在mysql.user表中为同一用户创建多条记录,因为根据用户连接的主机,您可以拥有不同的密码和/或权限。 If you run select * you will see the differences. 如果你运行select *,你会看到差异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM