Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql log files are empty although it seems that I have set eveything

Tags:

logging

mysql

I am trying to get log files for mysql server Ver 14.14 Distrib 5.5.22 running on debian-linux-gnu (x86_64) using readline 6.2

Based on several websites I uncommented these lines in /etc/mysql/my.cnf:

general_log_file        = /var/log/mysql/mysql.log 
general_log             = 1

After running mysql I checked that /var/log/mysql/mysql.log was not created. A website suggested to run two commands:

touch /var/log/mysql/mysql.log
chown mysql:mysql /var/log/mysql/mysql.log

This did not help: still no logs! The file is empty.

like image 850
elfar Avatar asked Jul 22 '12 08:07

elfar


People also ask

How do I view MySQL log files?

The data directory will typically be /var/lib/mysql/ or something similar, and it will serve as the default destination for any logs that are enabled without an alternate path. The log settings are managed via a user-editable configuration file such as /etc/mysql/mysql. conf. d/mysqld.

Where are MySQL error logs stored?

The MySQL server uses the error log to record information relevant to the error that prevents the server from starting. The error log is located in the data directory specified in your my. ini file.

How do I purge general logs in MySQL?

To force MySQL to start using new log files, flush the logs. Log flushing occurs when you execute a FLUSH LOGS statement or a mysqladmin flush-logs, mysqladmin refresh, mysqldump --flush-logs, or mysqldump --master-data command.


2 Answers

Did you restart the server after updating the my.cnf file?

Please issue:

SELECT @@global.general_log;
SELECT @@global.general_log_file;
SELECT @@global.log_output;

These are the de-facto variables as the server sees them. You may change tgem dynamically as follows:

SET GLOBAL general_log:=1;
SET GLOBAL log_output := 'FILE';

Also, as last resort, try:

FLUSH LOGS;

to close+reopen log file descriptor.

like image 85
Shlomi Noach Avatar answered Oct 15 '22 23:10

Shlomi Noach


I had the same issue with MySQL 5.5 at Ubuntu 14.04. Permisions and configurations were OK, but FLUSH LOGS returned

ERROR 1105 (HY000): Unknown error

Turned out, the issue was caused by incorrect AppArmor setup.

If this is the case the /var/log/syslog file contains lines like

<from kernel>: apparmor="DENIED" operation="mknod" profile="/usr/sbin/mysqld" name="/var/log/mysql/mysql.log" pid=16798 comm="mysqld" requested_mask="c" denied_mask="c" fsuid=115 ouid=115

Fix the AppArmor configuration in file /etc/apparmor.d/usr.sbin.mysqld and then restart AppArmor and MySQL.

like image 31
ENargit Avatar answered Oct 16 '22 01:10

ENargit