connection.connect(function(err) { if (err) { return console.error('error: ' + err.message); } console.log('Connected to the MySQL server.'); }); Code language: JavaScript (javascript)