对象不是mysql db中与nodejs一起使用的函数

对象不是mysql db中与nodejs一起使用的函数,mysql,node.js,Mysql,Node.js,我正在遵循以下步骤,但首先我出现了以下错误: deprecated: connect() is now done automatically object is not a function at Client.CALL_NON_FUNCTION_AS_CONSTRUCTOR (native) 我更改了代码,但之后我遇到了以下错误: deprecated: connect() is now done automatically object is not a function at Cli

我正在遵循以下步骤,但首先我出现了以下错误:

deprecated: connect() is now done automatically
object is not a function at Client.CALL_NON_FUNCTION_AS_CONSTRUCTOR (native)
我更改了代码,但之后我遇到了以下错误:

deprecated: connect() is now done automatically
object is not a function at Client.CALL_NON_FUNCTION_AS_CONSTRUCTOR (native)
我不知道,因为我是nodejs和mysql的新手,所以请帮助我

这是我的密码:

var Client = require('mysql').createClient({'host':'localhost','port':'3306','user':'root', 'password':''});
var client = new Client();

console.log('Connecting to mysql..');
ClientConnectionReady(client);

 ClientConnectionReady = function(client){
     client.query('USE login',function(err,result){
     if(err){
          console.log('cant create Table Error:'+ err.message);
      client.end();
      return;
 }
 ClientReady(client);
};



不确定这是导致您的特定消息的原因,但在
clientrady
中,您在执行
INSERT
之前正在调用
GetData
;您应该在
INSERT
的回调中执行此操作

更新:现在有人很友好地将所有内容正确缩进(提示:应该缩进的内容应该以4个空格开头),很明显您在
GetData()
中也遇到了类似的问题:您在回调有机会执行之前调用了
client.end()。因此,您的
SELECT
回调正在尝试使用关闭的MySQL连接,这可能是导致失败的原因