node和数据库建立连接

var express = require('express')
  , app = express();
var querystring = require('querystring');
var util = require('util');
var mysql  = require('mysql');  
var connection = mysql.createConnection({     
  host     : 'localhost',       
  user     : 'root',              
  password : '123456',       
  // port: '3306',                   
  database: 'test',  //数据库名称
}); 
 
connection.connect(); 

  

posted @ 2018-10-31 11:23  boyanh  阅读(996)  评论(0编辑  收藏  举报