如何在数据库中存储MySQL警告?

sso*_*zak 7 mysql logging warnings show

我想存储由数据库中的一些SQL语句引起的警告.比如之后

mysql> select 1/0;
+------+
| 1/0  |
+------+
| NULL |
+------+
1 row in set, 1 warning (0.00 sec)

mysql> show warnings;
+-------+------+---------------+
| Level | Code | Message       |
+-------+------+---------------+
| Error | 1365 | Division by 0 |
+-------+------+---------------+
1 row in set (0.00 sec)
Run Code Online (Sandbox Code Playgroud)

我想将SHOW WARNINGS所说的内容保存到某些持久表中,以便将来能够对其进行分析.

让我们假设我知道何时有记录的东西 - 我可以检查一下 @@warning_count > 0.

geo*_*kis 0

这还不够http://dev.mysql.com/doc/refman/5.0/en/server-options.html#option_mysqld_log-warnings吗?如果您想要的话,也许您可​​以解析 error.log 并将警告存储在数据库中。