The reason is that if the connection is lost due to network reasons after the node connects to mysql or the user closes the connection manually, the original connection will be suspended and the connection needs to be reconnected. The following code closes every access, the Code does not listen to the fatal error of the connection under the re-connection before each access starts. copy should be cautious [javascript] var mysql = require ('mysql'); var connection = mysql. createConnection ({host: 'localhost', user: 'root', password: '000000', database: 'test'}), slice = []. slice; var commonMethod = function (callback) {connection = mysql. createConnection (connection. config); connection. connect (); callback. call (connection, callback); connection. end () ;}; var onerror = function () {console. log (err) ;}; var query = function () {var args = arguments; commonMethod (function () {connection. query. apply (connection, args ). on ('error', onerror );});};