Reproduce MySQL error: The server closed the connection (node.js)

后端 未结 5 1795
你的背包
你的背包 2020-12-25 14:38

I\'m trying to reproduce a MySQL error I\'m seeing in my node.js app on EC2 with the node mysql library:

Connection lost: The server closed the connec

5条回答
  •  梦谈多话
    2020-12-25 15:37

    Check out mysql pool feature in node-mysql

    var mysql = require('mysql');
    var pool  = mysql.createPool({
      host     : 'example.org',
      user     : 'bob',
      password : 'secret'
    });
    
    pool.getConnection(function(err, connection) {
      // connected! (unless `err` is set)
      connection.end();
    });
    

提交回复
热议问题