测试 Charles Bell、Mats Kindahl 和 Lars Thalmann 所著书中的示例。我尝试使用指令“SHOW BINLOG EVENTS\G”检查 binlog。但它返回“空集 (0.00 秒)”。我错在哪里?这是 my.cnf:
[mysqld]
host = localhost
user = jun
password = 111
port = 3306
socket = /var/lib/mysql/mysqld.sock
pid-file = /var/lib/mysql/mysqld.pid
basedir = /var/lib/mysql
datadir = /usr
log-bin = /var/log/mysql/master-bin
log-bin-index = /var/log/mysql/master-bin.index
server-id = 1
tmpdir = /tmp
终端输出如下:
mysql> use test1;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select * from tb1;
+-------+
| text |
+-------+
| YEAH! |
+-------+
1 row in set (0.00 sec)
mysql> flush logs;
Query OK, 0 rows affected (0.00 sec)
mysql> SHOW BINLOG EVENTS\G
Empty set (0.00 sec)
mysql> exit
Bye
juneau@linux-dfxe:~> cd /var/log/mysql/
juneau@linux-dfxe:/var/log/mysql> ll
total 0
juneau@linux-dfxe:/var/log/mysql>
答案1
您需要验证 bin 日志文件是否已创建。我认为您没有正确指定文件路径。
log-bin = master-bin
通常,路径应该指定为绝对路径,例如:
log-bin = /var/log/mysql/master-bin
您需要确保 mysql 用户有足够的权限来创建/写入该文件。
答案2
哪个用户拥有 /var/log/mysql?mysql 错误日志中有哪些消息?如果是权限问题,mysql 将在日志中输出错误(如果我没记错的话,通常是错误 13)。