MySQL/MariaDB 如何查看当前的用户

MySQL 的所有数据库用户信息是存储在 user 数据表中的。

可以在登录成功数据后运行 SQL:

MariaDB [(none)]> select user,host from user;

就可以查看到数据中的所有用户信息。

MariaDB [(none)]> select user,host from user;
ERROR 1046 (3D000): No database selected
MariaDB [(none)]> select user,host from mysql.user;
+-------------+-----------+
| User        | Host      |
+-------------+-----------+
| root        | %         |
| webteam     | %         |
| yhu         | %         |
| crawler     | 192.168.% |
| 12          | localhost |
| mariadb.sys | localhost |
| mysql       | localhost |
+-------------+-----------+
7 rows in set (0.004 sec)

MariaDB [(none)]> 

2024-04-25_14-13-48

上面的表中显示了当前 MySQL 数据中所有的用户信息。

1 Like