不知道这里发生了什么,据我所知,所有内容都设置为应该是,但日志保持空白:
[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)
[更新]
我认为fedora 17使用覆盖my.cnf的参数启动mysql,日志不是my.cnf告诉它的地方:
[root@Laptop Symfony]# mysql -u root -p
mysql> select @@global.general_log_file;
+----------------------------+
| @@global.general_log_file |
+----------------------------+
| /var/lib/mysql/Laptop.log |
+----------------------------+
答案 0 :(得分:3)
首先,我会检查记录选项
在我的服务器上,我总是在/var/log
中创建一个新目录并将其“提供”给 mysql (作为 root 或通过须藤)
sudo mkdir /var/log/mysql
sudo chown mysql:mysql /var/log/mysql
然后 my.cnf 中的所有日志记录选项都是该目录中的文件
log=/var/log/mysql/general.log
log-error=/var/log/mysql/error.log
log-slow-queries=/var/log/mysql/slowquery.log
无论如何, mysql 可以创建和访问文件。此外,它有助于一次访问所有 mysql 日志文件,因为/var/log
目录非常繁忙,有很多与 mysql 无关的东西。
然后,为什么当前日志文件为空,可以在检查文件时缓冲一些日志信息。要强制 mysql 写入文件(或底层IO库)以便从外部 mysql (即tail
)可以看到文本,您可以执行(mysql命令)
FLUSH LOGS;
空日志文件中有interesting article。
答案 1 :(得分:2)
确保变量:general_log = ON,如果此变量为“OFF”,则mysql不会向general_log文件打印任何内容。
你可以检查mysql错误日志文件以查找是否有任何错误发生