转 怎么看mysql 的历史登陆情况

https://serverfault.com/questions/496216/viewing-usage-history-in-mysql

Viewing usage history in MySQL

 

Q:

We have Ubuntu 11.10 server that is running a LAMP stack, it was set up before I got here and no one knows what its for. I have to migrate it, or just shut it down but I need to know what its doing first.

Digging through it, there are no sites hosted off of it however there several databases created in MySQL.

So it may be connected to one of our sites but none of the devs here know.

What I need to do is view connection history on the MySQL databases do that I can find what, if anything, is connecting to them.

I am monitoring the processlist and not seeing any active connections.

 

A:

Mysql login logs can be enabled by starting mysql server with the option --log="log-file" option.

/usr/bin/safe_mysqld --log="/var/lib/mysql/mysql.log" &

Mysql log will be logged inside the file /var/lib/mysql/mysql.log. tail this file to see the logs. To see only the login (connect log) use the following command

grep Connect /var/lib/mysql/mysql.log

posted @ 2021-02-12 15:35  feiyun8616  阅读(457)  评论(0编辑  收藏  举报