原文
https://www.mysqltutorial.org/mysql-nodejs/connect/
let mysql =require('mysql') let connection = mysql.createConnection({ host:'119.91.31.144', user:'test1', password:'',//密码 database:'test1' }) // 连接数据库 connection.connect(function(err) { if (err) { return console.error('error: ' + err.message); } console.log('Connected to the MySQL server.'); }); // 关闭数据库 connection.end(function(err) { if (err) { return console.log('error:' + err.message); } console.log('Close the database connection.'); }); // 连接池 // var pool = mysql.createPool({ // connectionLimit: 5, // host: 'localhost', // user: 'root', // password: '', // database: 'todoapp' // });
标签:console,log,err,nodejs,connection,mysql,连接 From: https://www.cnblogs.com/hechunfeng/p/17477117.html