Jovica Ilic

linux | programming | startups | life

    • about
    • linkedIn
    • twitter
    • contact
    • BestHi.re [my weekend project]

How to enable General Query Log in MySQL under Linux

The general query log is a general record of what mysqld is doing. The server writes information to this log when clients connect or disconnect, and it logs each SQL statement received from clients. The general query log can be very useful when you suspect an error in a client and want to know exactly what the client sent to mysqld. More about General query log

So if you have some bug or problem with database, one of the way to trace the problem in turning on this log, and check what is happening.

General query log is disabled by default, and to enable it, in Linux, you should do this:

Edit mysql configuration file:

vi /etc/my.cnf

Enable logging file, under [mysqld] section:

log=/var/log/mysql.general.log

Save the file. Then create log file and set mysql ownership:

touch /var/log/mysql.general.log
chown mysql.mysql /var/log/mysql.general.log

Now, restart the mysql service:

/etc/init.d/mysql restart

You can now use your applications/scripts, run queries, etc. and everything will be logged. To see real time logging, run:

tail -f /var/log/mysql.general.log

Just be careful with this, log file can become big pretty fast.

When you want to disable General query log, just delete the line you have added in my.cnf, and restart mysql server.

 

Related Posts

  • How To Install and Configure freeNX
  • Reset Forgotten MySql root Password Under Windows
  • How to install LAMP (Apache MySQL and PHP) on CentOS
Tweet

21. July 2012 by jole
Categories: blog, Linux | Tags: General query log in Linux, Global query log in linux, how to disable general query log, how to enable general query log, How to enable General Query Log in MySQL under Linux, how to enable global query log | Leave a comment

Leave a Reply Cancel reply

Required fields are marked *


← Previous Post

Next Post →

  • Popular posts

    • Linux gets frozen, what do you do?
    • You’re in the front of a Linux computer, you need a root access. What do you do?
    • The story you should always keep in mind
    • The Inches We Need Are Everywhere Around Us
    • How to enable General Query Log in MySQL under Linux
  • Simple Daily Quotes

    History is a relentless master. It has no present, only the past rushing into the future. To try to hold fast is to be swept aside. - John F. Kennedy
    Tweet!
  • Subscribe

  • Blogs I read

    Pentester

© 2013 Jovica Ilic. Hosted on Adriahost