I'd like to monitor a MySQL 5.0.77 server and log every incoming connection for a day. I need to know who is connecting to the database.

I tried with the general logging but it's logging way too much and I can't keep it on long enough, log file is growing too fast.

Is there a way to do that ? Thanks

link|improve this question

54% accept rate
See this related bug report bugs.mysql.com/bug.php?id=28377 – Michael Mior Jul 7 '11 at 19:03
feedback

1 Answer

Here's an idea, but it might not work.
Create a FIFO pipe in /var/log/mysql/named_pipe In one end, get MySQL to use it as the general log file filename.

On the other end, set up something like

grep "login" < /var/log/mysql/named_pipe > /var/log/mysql/logins

You'll need to grep for whatever line it is exactly that you're after out of the log.

It might work.. it might not.

link|improve this answer
Even if this does work, there is a performance hit for all this logging. – Michael Mior Jul 7 '11 at 19:02
you want the data or not? You're gonna have to log it at some level. Other options might include mysql proxy, but you've still gotta write it to disk at some point – Tom O'Connor Jul 7 '11 at 19:04
mysql refuses to start when the log file is a FIFO pipe. I don't want to data, only the "Connect" information. I'm not worried about the performance hit if it's only for a day. – Bastien974 Jul 7 '11 at 19:10
1  
tcpdump or ngrep.. then scrape the information out of the packets. MySQL sucks. Especially when it's picky about it's log files. – Tom O'Connor Jul 7 '11 at 19:20
Well sure, you need to log it, but using the general log is overkill. – Michael Mior Jul 7 '11 at 20:34
show 1 more comment
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.