linux系统启动mysql日志,以下配置放在 [mysqld] 下面,代码如下:
- #查询日志
- log=/var/log/mysql_query.log
-
- #慢查询日志
- long_query_time = n 慢查询的执行用时上限(默认设置是10s)。
- log-slow-queries=/var/log/mysql_slowquery.log
-
- #更新日志
- server-id = 1
- log-bin = binlog
- log-bin-index = binlog.index
下面再附windows 启用mysql日志,以下是配置的整个过程,编辑my.ini,找到[msqld]部分,加入以下命令:
[mysql]
log="E:/mysqllog/mysql.log"
重启mysql,代码如下:
- mysql> show variables like "log%";
- +
- | Variable_name | Value |
- +
- | log | ON |
- | log_bin | ON |
- | log_bin_trust_function_creators | OFF |
- | log_error | ./ts17-113.err |
- | log_slave_updates | OFF |
- | log_slow_queries | OFF |
- | log_warnings | 1 |
- +
此处log行可以看到日志已经启用,打开E:/mysqllog/mysql.log,可以看到刚刚使用过的命令.
mysql.log文件,代码如下:
- D:/Program Files/MySQL/MySQL Server 5.0/bin/mysqld-nt, Version: 5.0.22-community-nt-log. started with:
- TCP Port: 3306, Named Pipe: (null)
- Time Id Command Argument
- 110704 15:57:39 1 Connect root@localhost on kbq
- 1 Query show variables like "log%"
- 110704 15:58:52 1 Query SELECT DATABASE()
- 110704 15:58:57 1 Query select * from test
- 110704 15:58:59 1 Query show tables
|