• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

50分,MySQL查询错误:Fatal error encountered during command execution

mysql 搞代码 7年前 (2018-06-05) 261次浏览 已收录 0个评论

50分,mysql查询异常:Fatal error encountered during command execution。
在使用存储过程查询时,出现错误提示:Fatal error encountered during command execution,每次发现查询时间较长时(超出40秒),出现的几率很大,但存储过程本身没什么问题,因为,同样条件,当查询数据较少时也不会出问题。
MySql版本:5.0.27
查询数据表记录大概有200万条,分页得出查询记录后,还要再关联(Join)两个表。

——解决方案——————–
代码贴出来看看,在连接字段上建立索引没有
——解决方案——————–
数据量好大,关注…
——解决方案——————–
内存不足?
——解决方案——————–
Description:
ExecuteReader() method of the MySqlCommand object displays "Fatal error encountered during
command execution" message when the simple statement below is executed.

select @data := 3, @data * 4;

How to repeat:
MySqlConnection con = new MySqlConnection();
con.ConnectionString = "Database=sampledb;Data Source=localhost;User Id=root;Password=a";
con.Open();
// Connection ok
string cmdText = "select @data := 3, @data * 4;";
MySqlCommand cmd = new MySqlCommand(cmdText, con);
MySqlDataReader r = cmd.ExecuteReader();
r.Read();
MessageBox.Show(r.GetInt32(1).ToString());
r.Close();
con.Close();
r.Dispose();
con.Dispose();[17 Nov 2008 17:26] Reggie Burnett 
Neoh

This is not a bug. You are attempting to use user variables in your sql. The default
mode for Connector/Net assumes you will not be using user variables (as most users don’t)
and so it sees @data and expects to find a parameter named @data. When it doesn’t find
one it throws an exception.

To fix this add ‘allow user variables=true’ to your connection string. In this mode it
will not complain when it sees @data but doesn’t find a parameter of that name.

你的存储过程是否使用了自定义变量?不过你说查询数据量少的时候不出问题,似乎和这个自定义变量又无关。
——解决方案——————–
1 我觉得是由于慢查询导致存储过程出现问题的。
2 在存储过程中增加一些异常机制处理,将出错的内容记录下来。
3 检查 MySQL 慢查询日志 和 Error 日志,看看是否有记录相关内容。
——解决方案——————–
关注下,呵呵。LZ给的细节过少了。


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:50分,MySQL查询错误:Fatal error encountered during command execution
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址