禁止MySQL警告? [英] Suppress MySQL warnings?
问题描述
可以说,我已经执行了触发一些警告消息的查询:
Lets say, I have executed a query that triggers some warning messages:
例如:
DROP TABLE IF EXISTS "abcd";
eg:
DROP TABLE IF EXISTS "abcd";
有没有一种方法可以只抑制正在触发的警告消息?
Is there a way to suppress only warning message that been triggering?
我看到有一个系统变量" max_error_count ",将其更改为零可能会忽略警告,但也会处理所有错误/注释消息.
I see there is a system variable "max_error_count", changing it to zero may ignore warnings but it would also do all errors/note messages.
推荐答案
Maybe the sql_notes variable helps you with this problem. Quote from the manpage:
sql_notes系统变量控制注释消息是否 增加warning_count以及服务器是否存储它们.经过 默认情况下,sql_notes为1,但是如果设置为0,则note不会递增 warning_count,服务器不存储它们:
The sql_notes system variable controls whether note messages increment warning_count and whether the server stores them. By default, sql_notes is 1, but if set to 0, notes do not increment warning_count and the server does not store them:
mysql> SET sql_notes = 1;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> SHOW WARNINGS;
+-------+------+------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------+
| Note | 1051 | Unknown table 'test.no_such_table' |
+-------+------+------------------------------------+
1 row in set (0.00 sec)
mysql> SET sql_notes = 0;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected (0.00 sec)
mysql> SHOW WARNINGS;
Empty set (0.00 sec)
这篇关于禁止MySQL警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!