注意中文编码问题:客户端代码建立connection时将charset设置为binary,这个与服务器端的默认latin1是兼容的。
var id3 = require("node-id3"),
path = require("path"),
fs_walk = require('fs-walk'),
mysql = require('mysql');
var pool = mysql.createPool({
host : 'localhost',
user : 'root',
password : '',
database : 'musicDB', //一般sql数据库名称需要在外部创建,里面的table可以在代码里创建
connectionLimit: 10,
charset: 'binary'
});
/*
CREATE TABLE music_info(
id INTEGER PRIMARY KEY AUTO_INCREMENT,
absPath VARCHAR(512) NOT NULL,
album VARCHAR(512),
artist VARCHAR(512),
title VARCHAR(512),
trackNumber INTEGER,
albumType CHAR
);
*/
//debug:
pool.on('acquire', function (connection) {
console.log('Connection %d acquired', connection.threadId);
});
pool.on('release', function (connection) {
console