小程序查询mysql数据库
小程序查询mysql数据库的步骤如下:
//引入mysql模块 var mysql = require('mysql'); //创建连接池 var pool = mysql.createPool({ connectionLimit : 10, host : 'localhost', user : 'root', password : '', database : 'test' }); //查询数据库 pool.query('SELECT * FROM student', function(error, results, fields) { if (error) throw error; console.log(results); });