MYSQL启用日志,查看日志

mysql有以下几种日志:
错误日志:     -log-err
查询日志:     -log
慢查询日志:   -log-slow-queries
更新日志:     -log-update
二进制日志: -log-bin

是否启用了日志
mysql>show variables like ‘log_%’;

怎样知道当前的日志
mysql> show master status;

显示二进制日志数目
mysql> show master logs;

看二进制日志文件用mysqlbinlog
shell>mysqlbinlog mail-bin.000001
或者shell>mysqlbinlog mail-bin.000001 | tail

在配置文件中指定log的输出位置.
Windows:Windows 的配置文件为 my.ini,一般在 MySQL 的安装目录下或者 c:Windows 下。
Linux:Linux 的配置文件为 my.cnf ,一般在 /etc 下。

在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

windows下:
Sql代码

1. # 在[mysqld] 中输入
2. #log
3. log-error=”E:/PROGRA~1/EASYPH~1.0B1/mysql/logs/error.log”
4. log=”E:/PROGRA~1/EASYPH~1.0B1/mysql/logs/mysql.log”
5. long_query_time=2
6. log-slow-queries= “E:/PROGRA~1/EASYPH~1.0B1/mysql/logs/slowquery.log”

# 在[mysqld] 中输入
#log
log-error=”E:/PROGRA~1/EASYPH~1.0B1/mysql/logs/error.log”
log=”E:/PROGRA~1/EASYPH~1.0B1/mysql/logs/mysql.log”
long_query_time=2
log-slow-queries= “E:/PROGRA~1/EASYPH~1.0B1/mysql/logs/slowquery.log”

开启慢查询
long_query_time =2  –是指执行超过多久的sql会被log下来,这里是2秒
log-slow-queries= /usr/local/mysql/log/slowquery.log  –将查询返回较慢的语句进行记录

log-queries-not-using-indexes = nouseindex.log  –就是字面意思,log下来没有使用索引的query

log=mylog.log  –对所有执行语句进行记录


( ! ) Warning: Missing argument 1 for cwppos_show_review(), called in /data/www/enjoyphp/wp-content/themes/flat/content-single.php on line 29 and defined in /data/www/enjoyphp/wp-content/plugins/wp-product-review/includes/legacy.php on line 18
Call Stack
#TimeMemoryFunctionLocation
10.0000355192{main}( ).../index.php:0
20.0001355480require( '/data/www/enjoyphp/wp-blog-header.php' ).../index.php:17
30.171510164520require_once( '/data/www/enjoyphp/wp-includes/template-loader.php' ).../wp-blog-header.php:19
40.172810235664include( '/data/www/enjoyphp/wp-content/themes/flat/single.php' ).../template-loader.php:74
50.261410791072get_template_part( ).../single.php:5
60.261410791592locate_template( ).../general-template.php:167
70.261410791688load_template( ).../template.php:643
80.261410792072require( '/data/www/enjoyphp/wp-content/themes/flat/content-single.php' ).../template.php:686
90.266810776792cwppos_show_review( ).../content-single.php:29

发表评论

电子邮件地址不会被公开。 必填项已用*标注