3

Not sure what's going on here, as far as I know everything is set as it's supposed to be but the log stays empty:

[root@myLaptop Me]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
[mysqld_safe]
log-error=/var/log/mysqld.log
log=/var/log/mysqld.general.log
general_log_file=/var/log/mysqld.general.log
pid-file=/var/run/mysqld/mysqld.pid
[root@myLaptop Me]# service mysqld stop
Redirecting to /bin/systemctl stop  mysqld.service
[root@myLaptop Me]# service mysqld start
Redirecting to /bin/systemctl start  mysqld.service
[root@myLaptop Me]# mysql -u root -p
Enter password: 
... Welcome stuff
Server version: 5.5.30 MySQL Community Server (GPL)
mysql> SET GLOBAL log_output = "FILE";SET GLOBAL general_log = 'ON';
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.05 sec)

mysql> SHOW PROCESSLIST;
+----+------+-----------+------+---------+------+-------+------------------+
| Id | User | Host      | db   | Command | Time | State | Info             |
+----+------+-----------+------+---------+------+-------+------------------+
|  3 | root | localhost | NULL | Query   |    0 | NULL  | SHOW PROCESSLIST |
+----+------+-----------+------+---------+------+-------+------------------+
1 row in set (0.00 sec)

mysql> quit
Bye
[root@myLaptop Me]# tail /var/log/mysqld.general.log 
[root@myLaptop Me]# <= shows nothing at all
[root@myLaptop Me]# ls -l /var/log/mysqld.general.log 
-rw-r--r--. 1 mysql mysql 0 May 31 10:06 /var/log/mysqld.general.log
[root@myLaptop Me]# tail /var/log/mysqld.log
130531 10:28:04 InnoDB: Completed initialization of buffer pool
130531 10:28:04 InnoDB: highest supported file format is Barracuda.
130531 10:28:04  InnoDB: Waiting for the background threads to start
130531 10:28:05 InnoDB: 5.5.30 started; log sequence number 2969208
130531 10:28:05 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
130531 10:28:05 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
130531 10:28:05 [Note] Server socket created on IP: '0.0.0.0'.
130531 10:28:05 [Note] Event Scheduler: Loaded 0 events
130531 10:28:05 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.5.30'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)

[update]

I think fedora 17 starts mysql with parameters that override the my.cnf the log is not where the my.cnf tells it to be:

[root@Laptop Symfony]# mysql -u root -p
mysql> select @@global.general_log_file;
+----------------------------+
| @@global.general_log_file  |
+----------------------------+
| /var/lib/mysql/Laptop.log |
+----------------------------+
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
HMR
  • 37,593
  • 24
  • 91
  • 160

2 Answers2

3

First, I would check the logging options

On my servers, I always create a new directory in /var/log and "give" it to mysql (to be executed as root or via sudo)

sudo mkdir /var/log/mysql
sudo chown mysql:mysql /var/log/mysql

then all logging options from my.cnf are a file inside that directory

log=/var/log/mysql/general.log
log-error=/var/log/mysql/error.log
log-slow-queries=/var/log/mysql/slowquery.log

to be sure in any case, mysql can create and access the files. Moreover, it helps to visit all the mysql log files at once, since the /var/log directory is pretty busy with many things not related to mysql.

Then, as why the current log files are empty, some log information may be buffered at the time you check the files. To force mysql to write to the files (or the underlying IO libraries) so that the text is visible from outside mysql (ie tail), you can execute (mysql command)

FLUSH LOGS;

There is an interesting article on empty log files.

Déjà vu
  • 28,223
  • 6
  • 72
  • 100
  • Thank you for your reply, even checking hours later the /var/log/mysqld.general.log is still empty maybe something is overriding the log location, when starting mysql maybe fedora adds command arguments that take priority over my.cnf Not sure how I could read out these values from mysql. – HMR May 31 '13 at 06:16
  • Yes, seems like mysql is ignoring the my.cnf completely when starting it with service mysqld start it probably adds startup parameters. I've updated my question with the actual location of the log in Fedora 17 – HMR May 31 '13 at 06:21
  • ring, could you be so kind as to add: select @@global.general_log_file; to check where mysql is logging. I can select your answer as the right one. – HMR May 31 '13 at 06:25
  • Mine is giving exactly what is in my *my.cnf* (which is a very private directory) - check again the `[mysqld]` section to ensure you don't have duplicate declarations. Beware also that there was a change in *cnf* location: check if you have a `/etc/mysql/` dir with *cnf* inside or if *my.cnf* is directly in `/etc` ... – Déjà vu May 31 '13 at 06:27
  • I'm not sure what is going on here tried to start mysqld like: su mysql;/usr/libexec/mysqld; No warnings or errors about config files but still logging to /var/lib/mysql/Laptop.log it's almost like the my.cgf may just as well not be there. – HMR May 31 '13 at 07:15
  • You have to start the service either from `/etc/init.d/mysql` or from `service mysql`... this is where the location of *my.cnf* is provided (or down to defaults). See also [this](http://stackoverflow.com/questions/580331/mysql-how-to-determine-which-config-file-is-being-used) or try to specify the location of the *cnf* file to *mysqld*. – Déjà vu May 31 '13 at 08:56
2

be sure that variable:general_log=ON,if this variable is "OFF",mysql will not print anything to general_log file.

you can check mysql error log file to look up is there any errors happened

  • Added general_log=ON in the my.cnf and get a log. I did re install the whole lot so there probably some other changes. Did not test it when removing that line (and setting it with a SQL statement) but it's working now – HMR Sep 30 '13 at 11:49