如果你是一个Web开发人员,你需要参考各种日志文件,以调试应用程序或改善其性能。日志是故障排除的最佳手段。对于著名的MySQLdatabase服务器(或MariaDB服务器),你需要参考以下日志文件:The Error Log. 包含服务器运行时发生的错误信息(也服务器启动和 ...
如果你是一个Web开发人员,你需要参考各种日志文件,以调试应用程序或改善其性能。日志是故障排除的最佳手段。对于著名的MySQLdatabase服务器(或MariaDB服务器),你需要参考以下日志文件:
- The Error Log. 包含服务器运行时发生的错误信息(也服务器启动和停止)
- The General Query Log. 这是mysqld运行的常规记录(连接,断开连接,查询)
- The Slow Query Log. slow SQL statements
这篇文章并不是指二进制日志。它需要非常高的标准服务器硬件,只有在特殊情况下(如复制,主 - 从机设置,某些数据恢复操作)是非常有用的。 除此之外,它只是一个“性能杀手”。
关于MySQL日志的官方文档 here.
注意: 如果你没有指定 Error log file, 默认在 (usually /var/lib/mysql in a file named {host_name}.err).
General Query log
注意: 如果你没有指定 General log file, 默认在 (usually /var/lib/mysqlin a file named {host_name}.log).
Slow Query log
注意: 如果你没有指定 Slow Query log file, 默认在 (usually/var/lib/mysql in a file named {host_name}-slow.log).
日志切割
不要忘记了切割日志.否则日志文件将会很大
In Debian (and Debian derivatives as Ubuntu etc)
其他版本,可能需要一些改变
查看变量配置
TIP: Use show variables like '%log%';
检验日志文件
官方文档 here.
何时启用日志
默认情况下,所有的日志被禁用 (windows下的错误日志除外).Debian下默认讲错误日志写入 syslog.
事实上,没有什么情况下,日志能解决关键问题(这里还是英文来表示比较合适)
- 总是启用错误日志.
- 启用查询日志 (preferably at runtime) 当出现以下几种情况
- check that your application handles correctly MySQL database connection (a common mistake is to connect multiple times to MySQL from a single script)
- monitor executed queries from your application
- test memcached (or similar software), checking out if a query was executed or memcached has handled the request
- 启用慢查询 (preferably from MySQL configuration file for a short period of time, e.g. 2-3 days) when your application performance is reduced for some reason and you should detect the slow queries.
示例
General query log:
原文:http://www.pontikis.net/blog/how-and-when-to-enable-mysql-logs
海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com
原标题:mysql中的日志(一)
关键词:MYSQL
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。