//win7环境下node要先安装MySQL的相关组件(非安装MySQL数据库),在cmd命令行进入node项目目录后执行以下语句 //npm install mysql var mysql = require('mysql'); var connection = mysql.createConnection({ host : 'localhost', port : '3306', user : 'root', password : '123456', database : 'test' });