创建一个连接池操作类 using MySql.Data.MySqlClient; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Timers; namespace CommonAssistant { public class MySqlConnectionPool { private readonly string sqlConnect = st
安装 mysql npm install mysql or cnpm install mysql 创建db.js,实现mysql操作模块 var mysql = require('mysql'); var db = {}; var pool = mysql.createPool({ host: 'localhost', port: 3306, user: 'root', password: 'root', database: 'demo' }); var exec = function (sql
两种方式解决1.你可以配置mysql的连接池 var mysql = require('mysql'); var pool = mysql.createPool({ host: 'localhost', user: 'nodejs', password: 'nodejs', database: 'nodejs', port: 3306 }); var selectSQL = 'select * from t_user limit 10'; pool.getConnection(function