【问题标题】:How to close the connection to MYSQL in nodejs node-mysql如何在nodejs node-mysql中关闭与MYSQL的连接
【发布时间】:2013-02-07 03:31:30
【问题描述】:

似乎有时与 MYSQL 的连接未关闭成功。我正在使用 nodejs 和 node-mysql 库。

client = mysql.createClient({ user: 'root', password: 'pass' });
client.query('USE db');
client.query( 'SELECT a FROM b ORDER BY c ASC', function selectCb(err, results, fields) {
  client.end();
  if (err) throw err;
  ....       
});

【问题讨论】:

    标签: mysql node.js


    【解决方案1】:

    希望有帮助!

    client.end(function(err) {
        // do what you want after the connection if closed :)
    });
    

    您也可以查看此链接:https://github.com/felixge/node-mysql#pooling-connections`

    【讨论】:

      猜你喜欢
      • 2016-02-08
      • 1970-01-01
      • 1970-01-01
      • 2022-01-02
      • 1970-01-01
      • 2016-08-08
      • 1970-01-01
      • 2018-10-30
      • 1970-01-01
      相关资源
      最近更新 更多