博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Mysql打开日志信息
阅读量:7090 次
发布时间:2019-06-28

本文共 2231 字,大约阅读时间需要 7 分钟。

还可参考博客:

1)怎么查看mysql是否启用了日志

mysql>show variables like 'log_%';

没有手动打开的话,都是关闭的状态.

2)mysql有以下几种日志:

   错误日志:     -log-err 

   查询日志:     -log 
   慢查询日志:    -log-slow-queries 
   更新日志:      -log-update 
   二进制日志:  -log-bin 

   在mysql的安装目录下,打开my.ini,在后面加上上面的参数,保存后重启mysql服务就行了。 

   例如:
   #Enter a name for the error log file.   Otherwise a default name will be used.
   log-error=err.log
   #Enter a name for the query log file. Otherwise a default name will be used.
   #log=
   #Enter a name for the slow query log file. Otherwise a default name will be used.
   #log-slow-queries=
   #Enter a name for the update log file. Otherwise a default name will be used.
   #log-update=
   #Enter a name for the binary log. Otherwise a default name will be used.
   #log-bin=     
   上面只开启了错误日志,要开其他的日志就把前面的“#”去掉。

我的配置如下:

#Log to file#Enter a name for the error log file.   Otherwise a default name will be used.log-error="F:/Program Files (x86)/MySQL/MySQL Server 5.5/data/err.log"#Enter a name for the query log file. Otherwise a default name will be used.log="F:/Program Files (x86)/MySQL/MySQL Server 5.5/data/mySQL.log"#Enter a name for the slow query log file. Otherwise a default name will be used.log-slow-queries="F:/Program Files (x86)/MySQL/MySQL Server 5.5/data/query.log"#Enter a name for the update log file. Otherwise a default name will be used.#log-update="F:/Program Files (x86)/MySQL/MySQL Server 5.5/data/update.log"#Enter a name for the binary log. Otherwise a default name will be used.log-bin="F:/Program Files (x86)/MySQL/MySQL Server 5.5/data/bin.log"

 

①等号= 后面的有点文章直接写的文件名,说重启Mysql服务之后就会生成对应的日志文件...我尝试无果,写绝对路径可以.

②如果打开上面的log-update配置项,重启Mysql就会报错....注释掉就重启就没有问题,目前不知道什么原因.

生成了对应的日志文件(bin文件每次重启mysql就生成一个.....)

此外这个地方还可以设置多个配置项:

下面是配置日志的几种方式,不一定全都要配置,请根据自身需求选择性配置log=mylog.log --对所有执行语句进行记录log-error=log-error.loglog=log-query.loglog-queries-not-using-indexes=nouseindex.loglog-warnings=2log-slow-queries=log-slow-query.loglog-update=log-update.loglong_query_time=2  (开启慢查询)

 

开启慢查询

long_query_time =2 --是指执行超过多久的sql会被log下来,这里是2秒
log-slow-queries="E:/PROGRA~1/EASYPH~1.0B1/mysql/logs/slowquery.log" --将查询返回较慢的语句进行记录

记录没有使用索引的query

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

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

3)查看当前的日志

mysql> show master status; 

4)显示二进制日志数目

mysql>show master logs;

 

转载地址:http://ytfql.baihongyu.com/

你可能感兴趣的文章
【算法导论】学习笔记——第10章 基本数据结构
查看>>
BNUOJ52317 As Easy As Possible(树上倍增)
查看>>
STL源码阅读(一)
查看>>
c-28
查看>>
华为交换机重置密码案例
查看>>
17素材下载地址
查看>>
Jquery EasyUI1.3.1 JS加载出错
查看>>
LA 4794 Sharing Chocolate (搜索)
查看>>
Yahoo团队网站性能优化的35条黄金守则
查看>>
secureCrt Linux 文件传输
查看>>
JaveWeb 公司项目(1)----- 使Div覆盖另一个Div完成切换效果
查看>>
hdu6078[优化递推过程] 2017多校4
查看>>
zabbix 配置报警方式
查看>>
Eclipse将android项目打包jar文件
查看>>
Spring Security实现RBAC权限管理
查看>>
Struts2返回json
查看>>
ZROI2018提高day3t3
查看>>
cf123E Maze
查看>>
bzoj2839 集合计数
查看>>
Static和extern关键字 c
查看>>