访问数据库的用户列表 [英] List of users accessing database

查看:86
本文介绍了访问数据库的用户列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由一组队友访问的MySQL数据库.是否有任何命令可获取当前正在访问的用户或已经访问并注销的用户的日志信息?

I have a MySQL database accessed by a group of my teammates. Is there any command to get the log information of the users who are currently accessing or who have already accessed and logged out?

推荐答案

从mysql工具运行以下命令以查看当前所有正在运行的进程(包括睡眠连接):

Run the following from a mysql tool to view all currently running processes (including sleeping connections):

SHOW PROCESSLIST

或者,您可以查询information_schema表以获取相同的信息:

Or, you can query the information_schema table to get the same:

select * from information_schema.processlist

要查看所有登录者的历史记录,可以通过将以下启动参数添加到mysqld启动中来配置常规查询日志以进入表"--log-output = TABLE --general-log ",那么您可以从mysql模式中的general_log表中查询此信息.以下是您可以使用的查询:

To see a history of whom all has logged in, you could configure the general query log to go to a table, by adding the following startup parameter to your mysqld startup "--log-output=TABLE --general-log", then you can query this information out of the general_log table in the mysql schema. Following is the query you could use:

select * from mysql.general_log where command_type = 'Connect';

警告一下,这张桌子可能很大.您需要定期清理它.

A word of warning though, this table could get huge. You'll want to periodically clean it out.

这篇关于访问数据库的用户列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆