无法使用JS和MySql正确连接到数据库

时间:2018-11-11 05:53:40

标签: javascript mysql

我已经进行了一些研究,但似乎找不到问题。我的数据库根本无法连接。

var con = mysql.createConnection({
  host: "***********",
  user: "NodeSupport",
  password: "**********",
  database: 'NodeBot',
  port: 2083,
});

con.connect(function(err) {
  if (err) throw err;
  console.log("Connected!");
});

主机是您在PhpmyAdmin页面上看到的IP地址。 密码和用户名是链接到数据库的我的mysql帐户。

我发现自己看到了这个错误

Error: Packets out of order. Got: 80 Expected: 0
    at Parser.write (C:\Users\Matthew\Desktop\Extras\DiscordBot\node_modules\mysql\lib\protocol\Parser.js:42:19)
    at Protocol.write (C:\Users\Matthew\Desktop\Extras\DiscordBot\node_modules\mysql\lib\protocol\Protocol.js:38:16)
    at Socket.<anonymous> (C:\Users\Matthew\Desktop\Extras\DiscordBot\node_modules\mysql\lib\Connection.js:91:28)
    at Socket.<anonymous> (C:\Users\Matthew\Desktop\Extras\DiscordBot\node_modules\mysql\lib\Connection.js:502:10)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)
    at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
    --------------------
    at Protocol._enqueue (C:\Users\Matthew\Desktop\Extras\DiscordBot\node_modules\mysql\lib\protocol\Protocol.js:144:48)
    at Protocol.handshake (C:\Users\Matthew\Desktop\Extras\DiscordBot\node_modules\mysql\lib\protocol\Protocol.js:51:23)
    at Connection.connect (C:\Users\Matthew\Desktop\Extras\DiscordBot\node_modules\mysql\lib\Connection.js:118:18)
    at Object.<anonymous> (C:\Users\Matthew\Desktop\Extras\DiscordBot\index.js:71:5)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

编辑-它永远不会记录“已连接”

0 个答案:

没有答案