How to get a list of MySQL user accounts

2019-01-29 14:53发布

I'm using the MySQL command line utility and can navigate through a database. Now I need to see a list of user accounts. How can I do this?

I'm using MySQL version 5.4.1.

标签: mysql mysql5
14条回答
聊天终结者
2楼-- · 2019-01-29 15:17

Peter and Jesse are correct but just make sure you first select the mysql DB.

use mysql;

select User from mysql.user;

that should do your trick

查看更多
地球回转人心会变
3楼-- · 2019-01-29 15:21

MySQL stores the user information in its own database. The name of the database is MySQL. Inside that database, the user information is in a table, a dataset, named user. If you want to see what users are set up in the MySQL user table, run the following command:

SELECT User, Host FROM mysql.user;

+------------------+-----------+
| User             | Host      |
+------------------+-----------+
| root             | localhost |
| root             | demohost  |
| root             | 127.0.0.1 |
| debian-sys-maint | localhost |
|                  | %         |
+------------------+-----------+
查看更多
登录 后发表回答