728x90
var mysql = require('mysql');
// 데이터베이스와 연결합니다.
var client = mysql.createConnection({
user:'사용자',
password:'비밀번호',
host:'호스트',
port: 3306,
database: '데이터베이스'
});
// 명시적으로 연결
client.connect();
client.query('SELECT 1 + 1 AS solution', function(err, rows, fields) {
if (err) throw err;
console.log('The solution is: ', rows[0].solution);
console.log(rows);
console.log(fields);
});
// 명시적으로 연결 해제
client.end();
728x90
'Develop > Etc' 카테고리의 다른 글
| [Node.js]Jade 템플릿 엔진 (0) | 2016.10.17 |
|---|---|
| [Node.js]Express 설치 (0) | 2016.10.17 |
| [Node.js]웹 애플리케이션 만들기 (0) | 2016.10.17 |
| 서브라임텍스트 SFTP 설정 (0) | 2016.10.11 |
| ICT란? (0) | 2016.10.02 |
댓글