Home > Database > Mysql Tutorial > node使用mysql操作数据库_MySQL

node使用mysql操作数据库_MySQL

WBOY
Release: 2016-06-01 13:11:01
Original
1133 people have browsed it

var mysql =require(“mysql”);
console.log(“con….“);

var connection=mysql.createConnection({

"host":"localhost",  "port":3306,  "user":"root",  "password":"wjb1234",  "database":"test"
Copy after login

});

connection.connect();
console.log(“conned…“);

var select =“select * from test “;

connection.query(select,function(err,rows){

if(err) console.log(err.message);     for( var i in rows){          console.log(rows[i]);     }
Copy after login

});

connection.end();

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template