MySQL 错误 #2014 - 命令不同步;你现在不能运行这个命令

2021-12-20 00:00:00 mysql stored-procedures

我正在使用 MySQL,我正在定义一个这样的存储过程:

I am using MySQL and I am defining a stored procedure like this:

delimiter ;;
Create procedure sp_test()

  select * from name_table;
end

当我尝试执行该过程时出现此错误:

When I try to execute that procedure I get this error:

#2014 - Commands out of sync; you can't run this command now 

这是什么意思,我做错了什么?

What does this mean and what am I doing wrong?

推荐答案

来自 手册

C.5.2.14.命令不同步
如果 命令不同步;你现在无法在您的客户端代码中运行此命令,您正在调用客户端功能顺序错误.

C.5.2.14. Commands out of sync
If you get Commands out of sync; you can't run this command now in your client code, you are calling client functions in the wrong order.

这可能发生,例如,如果您使用 mysql_use_result() 并且尝试在调用 mysql_free_result() 之前执行新查询.如果您尝试执行两个返回数据的查询,也会发生这种情况无需调用 mysql_use_result()mysql_store_result() .

This can happen, for example, if you are using mysql_use_result() and try to execute a new query before you have called mysql_free_result(). It can also happen if you try to execute two queries that return data without calling mysql_use_result() or mysql_store_result() in between.

这篇文章(取自这里)

我已经解决了这个问题.我使用 MySQL-Fron 代替 MySQL Query浏览器.一切正常.

I've solved that problem. I use MySQL-Fron instead MySQL Query browser. And everything works fine.

让我认为这不是服务器或数据库问题,而是您使用的工具的问题.

makes me think that it's not a server or database problem but a problem in the tool you're using.

相关文章