mysql有以下几种日志:
错误日志: -log-err
查询日志: -log
慢查询日志: -log-slow-queries
更新日志: -log-update
二进制日志: -log-bin
顯示二進制日志數目
mysql> show master logs;
看二进制日志文件用
mysqlbinlog
shell>mysqlbinlog mail-bin.000001
或者shell>mysqlbinlog mail-bin.000001 | tail
1.首先确认是否启用了日志
mysql> show variables like 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin | ON |
+---------------+-------+
1 row in set (0.00 sec)
mysql>
2.如果启用了,即ON
那日志文件就在mysql的安装目录的data目录下
3.怎样知道当前的日志
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000014 | 22029080 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
mysql>
4.看二进制日志文件用
mysqlbinlog
#/usr/local/mysqlbin/mysqlbinlog mail-bin.0000014
或者mysqlbinlog mail-bin.0000014 | tail
在linux下:
Sql代码
1. # 在[mysqld] 中輸入
2. #log
3. log-error=/usr/local/mysql/log/error.log
4. log=/usr/local/mysql/log/mysql.log
5. long_query_time=2
6. log-slow-queries= /usr/local/mysql/log/slowquery.log
# 在[mysqld] 中輸入
#log
log-error=/usr/local/mysql/log/error.log
log=/usr/local/mysql/log/mysql.log
long_query_time=2
log-slow-queries= /usr/local/mysql/log/slowquery.log