mysql中如何查看日志

开发技术 作者:Leah 2024-03-27 06:35:01
今天就跟大家聊聊有关mysql中如何查看日志,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。是否启...

今天就跟大家聊聊有关mysql中如何查看日志,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

是否启用了日志
>show variables like 'log_bin';
 
怎样知道当前的日志
mysql> show master status;
 
看二进制日志文件用mysqlbinlog
shell>mysqlbinlog mail-bin.000001(要写绝对问题路径d://)
或者shell>mysqlbinlog mail-bin.000001 | tail
 
Windows 下用类似的命令。
 
 
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=     
   上面只开启了错误日志,要开其他的日志就把前面的“#”去掉。
 
long_query_time =1 --是指执行超过多久的sql会被log下来,这里是1秒
 
log-slow-queries=slowqueris.log --将查询返回较慢的语句进行记录
 
log-queries-not-using-indexes = nouseindex.log --就是字面意思,log下来没有使用索引的query
 
log=mylog.log --对所有执行语句进行记录
 
log-error=log-error.log
log=log-query.log
log-queries-not-using-indexes
log-warnings=2
log-slow-queries=log-slow-query.log
log-update=log-update.log
long_query_time=2

看完上述内容,你们对mysql中如何查看日志有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注捷杰建站行业资讯频道,感谢大家的支持。

原创声明
本站部分文章基于互联网的整理,我们会把真正“有用/优质”的文章整理提供给各位开发者。本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
本文链接:http://www.jiecseo.com/news/show_685.html
mysql