首页 / 日志 / 如何查询MySql日志
如何查询MySql日志
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了如何查询MySql日志,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含5535字,纯文字阅读大概需要8分钟。
内容图文
![如何查询MySql日志](/upload/InfoBanner/zyjiaocheng/457/e1dcfbed2ad8425c94ae51534ac698ce.jpg)
如何查询MySql日志
分类: mysql2012-02-23 19:14 26756人阅读 评论(2) 收藏 举报 mysqlcommandprintingserversocketoutput今天美国老板发来一封email,一句What happen to ...? 其他任何线索没有,我的给出答案,一一排查,看能否找到问题缘由或是恢复数据,更新问题?程序问题?结果都是没有头绪,最后想了下mysql的日志看能否看看,以前没看过mysql的日志,查查资料,最终皇天不负有心人,搞定了,现在总结下:
1.首先确认你日志是否启用了
- MySQL>show variables like ‘log_bin‘;
2.如果启用了,即ON那日志文件就在MySQL的安装目录的data目录下
3.怎样知道当前的日志
- MySQL> show master status;
4.看二进制日志文件用MySQLbinlog
- shell>MySQLbinlog mail-bin.000001
或者
- shell>MySQLbinlog mail-bin.000001 | tail
[hx@localhost data]$ mysqlbinlog mysqlbinlog Ver 3.0 for pc-linux-gnu at i686 By Monty and Sasha, for your professional use This software comes with NO WARRANTY: This is free software, and you are welcome to modify and redistribute it under the GPL license
Dumps a MySQL binary log in a format usable for viewing or for piping to the mysql command line client
Usage: mysqlbinlog [options] log-files -d, --database=name List entries for just this database (local log only). -D, --disable-log-bin Disable binary log. This is useful, if you enabled --to-last-log and are sending the output to the same MySQL server. This way you could avoid an endless loop. You would also like to use it when restoring after a crash to avoid duplication of the statements you already have. NOTE: you will need a SUPER privilege to use this option. -f, --force-read Force reading unknown binlog events. -?, --help Display this help and exit. -h, --host=name Get the binlog from server. -o, --offset=# Skip the first N entries. -p, --password[=name] Password to connect to remote server. -P, --port=# Use port to connect to the remote server. -j, --position=# Deprecated. Use --start-position instead. --protocol=name The protocol of connection (tcp,socket,pipe,memory). -r, --result-file=name Direct output to a given file. -R, --read-from-remote-server Read binary logs from a MySQL server --open_files_limit=# Used to reserve file descriptors for usage by this program -s, --short-form Just show the queries, no extra info. -S, --socket=name Socket file to use for connection. --start-datetime=name Start reading the binlog at first event having a datetime equal or posterior to the argument; the argument must be a date and time in the local time zone, in any format accepted by the MySQL server for DATETIME and TIMESTAMP types, for example: 2004-12-25 11:25:56 (you should probably use quotes for your shell to set it properly). --stop-datetime=name Stop reading the binlog at first event having a datetime equal or posterior to the argument; the argument must be a date and time in the local time zone, in any format accepted by the MySQL server for DATETIME and TIMESTAMP types, for example: 2004-12-25 11:25:56 (you should probably use quotes for your shell to set it properly). --start-position=# Start reading the binlog at position N. Applies to the first binlog passed on the command line. --stop-position=# Stop reading the binlog at position N. Applies to the last binlog passed on the command line. -t, --to-last-log Requires -R. Will not stop at the end of the requested binlog but rather continue printing until the end of the last binlog of the MySQL server. If you send the output to the same MySQL server, that may lead to an endless loop. -u, --user=name Connect to the remote server as username. -l, --local-load=name Prepare local temporary files for LOAD DATA INFILE in the specified directory. -V, --version Print version and exit.
Variables (--variable-name=value) and boolean options {FALSE|TRUE} Value (after reading options) --------------------------------- ----------------------------- database (No default value) disable-log-bin FALSE force-read FALSE host (No default value) offset 0 port 3306 position 4 read-from-remote-server FALSE open_files_limit 64 short-form FALSE socket (No default value) start-datetime (No default value) stop-datetime (No default value) start-position 4 stop-position 18446744073709551615 to-last-log FALSE user (No default value) local-load (No default value)
2009.09.30 检查一个应用的问题的时候,发现通过 oracle 的 dblink 连接 mysql 进行更新等操作的时候,mysql 不会把操作的 sql 语句记录到日志文件里,有点点郁闷了
如何查询MySql日志
标签:
本文系统来源:http://www.cnblogs.com/u0mo5/p/4780931.html
内容总结
以上是互联网集市为您收集整理的如何查询MySql日志全部内容,希望文章能够帮你解决如何查询MySql日志所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。