Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to put some (minimal) logging on our MySQL server, with the aim of determining which DBs on the server aren't being regularly accessed. We intend to log for approximately a month, and any DBs which aren't accessed by clients over this time we want to archive.

Could someone please point me in the right direction regarding this - most of the logging tutorials I found on the web were concerned with logging actual SQL queries etc., whereas I just want a "Connection made from Client IP X at Time Y to DB Z" logged.

Thanks in advance.



share|improve this question
up vote 3 down vote accepted

You can use init_connect parameter to execute query on user log-on, e.g.

SET GLOBAL init_connect = "INSERT INTO admin.connections (connect_time, user, connection_id) VALUES (NOW(), CURRENT_USER(), CONNECTION_ID());";

See this for more detailed explanation.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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