我有一个con_mysql.js
包含以下内容的文件:
var client = require('mysql');
client.createClient({'host':'localhost','port':3306,'user':'root','password':'root'});
client.connect();
然后:
# node con_mysql.js
chris:db chris$ node my.js
/Users/chris/node_modules/mysql/lib/client.js:40
throw new Error('deprecated: connect() is now done automatically.');
^
Error: deprecated: connect() is now done automatically.
at Client.connect (/Users/chris/node_modules/mysql/lib/client.js:40:9)
at Object.<anonymous> (/Users/chris/jswork/nodejs/db/con_mysql.js:5:8)
at Module._compile (module.js:446:26)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
at Function._load (module.js:311:12)
at Array.0 (module.js:484:10)
at EventEmitter._tickCallback (node.js:190:38)
我该如何解决这个问题?
我已经安装了这样的mysql模块:
# npm install mysql