zoukankan      html  css  js  c++  java
  • Mysql打开日志信息

    还可参考博客:http://pangge.blog.51cto.com/6013757/1319304

    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.log
    log=log-query.log
    log-queries-not-using-indexes=nouseindex.log
    log-warnings=2
    log-slow-queries=log-slow-query.log
    log-update=log-update.log
    long_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;

  • 相关阅读:
    格式化输出数字
    传教士经验
    集合
    替换
    连接
    填充
    取值
    分割
    创建日历和日期列表
    常用日期格式
  • 原文地址:https://www.cnblogs.com/DreamDrive/p/5761005.html
Copyright © 2011-2022 走看看