0
  • I have a WHM/Cpanel re-seller hosting account on a virtual private server (Linux).
  • I have root access to the machine via SSH

I am trying to locate a file that contains information that will help me to determine which users have accessed what db and from which hosts.

I would imagine this kind of data is stored in a log file somewhere.

The MySQL page says:

The general query log - Established client connections and statements received from clients

See: http://dev.mysql.com/doc/refman/5.0/en/server-logs.html

It also says:

By default, all log files are created in the mysqld data directory. 

So, I am am NOT asking where are the general query log logs stored, (cos I expect I will get answers saying "it depends")

Please help me work out:

"How can go about finding out where MySQL general query log logs are stored on a linux machine"

Couple of things i've already tried:

I looked at

 /etc/my.cnf

it was a tiny file that only contained the following info:

[mysqld]
skip-bdb
skip-innodb
set-variable = max_connections=500
safe-show-database
~
~

I have looked in:

/var/lib/mysql/

But I could not see any log-like file names in that directory.

Any clues on this would be most welcome.

4 Answers 4

1

To ask MySQL where it is storing the general logs (and whether they are on or not), you can simply type:

 show variables like 'general_log%';

Into a MySQL command prompt (or run the query from phpmyadmin).

e.g.

mysql> show variables like 'general_log%';
+------------------+----------------------------+
| Variable_name    | Value                      |
+------------------+----------------------------+
| general_log      | OFF                        |
| general_log_file | /var/run/mysqld/mysqld.log |
+------------------+----------------------------+

I think that's what you're asking for.

0

You need to enable the general query log specifically at the command line:

mysqld ... --log=[filename]
mysqld .. -l [filename]

Look at mysqld's command line in the output of ps ax to determine if and where your server is logging information.

FWIW, The default location for the general log is the same directory as the data files and it is named [hostname].log.

NB: if you enable the general query log, the log can get large very quickly.

1
  • thanks. So do you mean i just login via SSH and type [# ps ax] into the SSH command line and it will tell me. I have looked up the man page for "ps" but cannot see how it relates to "ax". Anyway - its a start thanks - i will try it out.
    – moi
    Nov 13, 2009 at 7:31
0

On Debian, mysql logs are usually stored under /var/log/mysql/. Derivatives like Ubuntu will also have logs there. If logrotate is installed, it will keep gzipped copies of daily mysql logs for several days (this is configurable).

I assume other Linux distros could have logs in a similar location, e.g. /var/logs/something.

As serverninja points out, general log is disabled by default - so you have to enable it, either from my.cnf or a command line. It will hurt performance badly!

0

It is supposed to be within /var/lib/mysql/
ENABLE your general query log

You must log in to answer this question.