在 mysql 数据库配置中将命令超时更新为 0

Update command timeout to 0 in mysql db configuration

如何更新 mysql 数据库中的命令超时。我知道如何在应用程序级别执行此操作,但我想更改 db end 处的命令超时。所以我只需要在一个地方改变它。 在应用程序结束时,我使用

"default command timeout = 0"

它工作正常。但是谁能告诉我如何在数据库端做同样的事情?

答案是:你不能。为什么?因为 command timeout 特定于 MySQL .Net 连接器:

Sets the default value of the command timeout to be used. This does not supersede the individual command timeout property on an individual command object. If you set the command timeout property, that will be used. This option was added in Connector/Net 5.1.4

正如 MySQL 关于 MySqlCommand object 的文档所说:

Prior to MySQL Connector/Net 6.2, MySqlCommand.CommandTimeout included user processing time, that is processing time not related to direct use of the connector. Timeout was implemented through a .NET Timer, that triggered after CommandTimeout seconds. This timer consumed a thread.

MySQL Connector/Net 6.2 introduced timeouts that are aligned with how Microsoft handles SqlCommand.CommandTimeout. This property is the cumulative timeout for all network reads and writes during command execution or processing of the results. A timeout can still occur in the MySqlReader.Read method after the first row is returned, and does not include user processing time, only IO operations. The 6.2 implementation uses the underlying stream timeout facility, so is more efficient in that it does not require the additional timer thread as was the case with the previous implementation.

因此,在 6.2 之前,命令超时包括客户端处理时间 - 这显然不能在服务器端考虑。

从 6.2 开始,行为发生了变化,不包括客户端处理时间。但是,现在定义为 "累积 所有网络读写超时"。在 MySQL 服务器中,您可以配置各种超时,但这些超时不是累积的,也不适用于读取和写入。只有单独的读取和写入超时。因此,没有此连接器参数到 MySQL 配置的映射。