Mysql – Enabling general_log in MySQL 5.1.52 on RHEL6

loggingMySQLredhat

So I am a bit on the fresh side of things when talking about Linux server management. I am currently trying to enable general logging for MySQL on a box I am managing that is running RHEL6. Based on everything I have read I should be able to enable both slow query logging and general query logging using the following command

/etc/rc.d/init.d/mysqld start --general_log=1 --log-output=TABLE --slow_query_log=1

This should, based on what I know, enable general logging to the mysql.general_log table (in addition to mysql.slow_log table. Unfortunately, though, when I do this and then check the global variables in MySQL I see the following.

general_log   |   OFF

I looked in to the mysqld manual and it said that I could do the following to see all of the commands / switches I could supply mysqld.

mysqld --verbose --help

So I try doing the following

/etc/rc.d/init.d/mysqld --verbose --help

And when I do that I see the following

Usage: /etc/rc.d/init.d/mysqld {start|stop|status|restart|condrestart|try-restart|reload|force-reload}

I feel like I have run in to this situation in the past where the daemon that resides in the /etc/rc.d/init.d directory is in fact not the daemon I need to be issuing commands to, but I can't seem to find any other mysqld.

My questions are the following:

  1. What am I not getting here?
  2. Is there another location specific to RHEL where daemons reside?

Thank you in advance for the help!

Best Answer

You're actually going about this the wrong way. All you need to do is edit the file /etc/my.cnf and add these directives:

#Enable general query logging
general_log=1
general_log_file=/var/log/mysqld-general.log

Then restart the MySQL daemon:

/etc/init.d/mysqld restart

And you will then have enabled the general_log