How to find information (user/pass, IP address of the logged in user) regarding the users who connect to mysql (eithe开发者_开发知识库r programmatically via JDBC driver) or via the command line shell to perform a certain operation. Would like to know, if this information can be obtained via a SQL table.
MySQL does not directly give a method of tracking logins. However, the init_connect
system variable can be set to a command to be executed when a new user logs in. You could make use of this to insert the values of USER()
and NOW()
into an auditing table.
SHOW PROCESSLIST
might give you some of the information you required -> http://dev.mysql.com/doc/refman/5.1/en/show-processlist.html
Even better than that is the General Query Log -> http://dev.mysql.com/doc/refman/5.5/en/query-log.html
But its not enabled by default.....but can be logged to a table !
精彩评论