禁止MySQL警告?

编程入门 行业动态 更新时间:2024-10-11 19:18:18
本文介绍了禁止MySQL警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

可以说,我已经执行了触发一些警告消息的查询:

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.

推荐答案

也许 sql_notes 变量可帮助您解决此问题. 从联机帮助页引用:

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警告?

本文发布于:2023-11-09 07:41:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571761.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:MySQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!