mysql - Node.js MySQL NPM 错误 "Cannot switch to old mode now."

标签 mysql node.js

通过mysql npm发出查询时,Node.js 抛出以下错误.

_stream_readable.js:664
throw new Error('Cannot switch to old mode now.');

Error: Cannot switch to old mode now.
at emitDataEvents (_stream_readable.js:664:11)
at Socket.Readable.resume (_stream_readable.js:649:3)

引发此错误的示例代码:

query  = mysqlCLI.query( 'SELECT * FROM foo WHERE bar = 1' );
results = [];

mysqlCLI.resume();

query

  .on( 'error', function ( err ) {

    console.log( 'Bad Things: ', err );

  })

  .on( 'result', function ( row ) {

      results.push( row );

  })

  .on( 'end', function (){

    mysqlCLI.pause();

    dataHandler( results );

  });

最佳答案

这需要大量的故障排除,但最终的解决方法是删除 mysqlCLI.pause();mysqlCLI.resume();。这个问题的奇怪之处在于,代码在 Windows Server 2003 上执行得很好,但当我通过 Git 克隆后,它在 CentOS 5.9 (RHEL) 下就崩溃了。

关于mysql - Node.js MySQL NPM 错误 "Cannot switch to old mode now.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15889205/

相关文章:

node.js - 在项目中安装包后运行 npm 脚本

javascript - 页面加载之前传递的 Mocha 断言

node.js - Express/Mongoose 使用对象函数作为回调不起作用

mysql - 关于日期时间类型值的问题

php - 如果 mySQL 行为空,if else 语句不返回任何值?

mysql - 计算用户出价最高的所有项目

python - 限制 mysql 查询中的 str 字符

node.js - Backbone.js 和 Node.js : Looking for a best practice for application settings

mysql - 查询中的sequulizejs WHERE `where`

python - 为什么mysql connector break ("Lost connection to MySQL server during query"错误)