gpt4 book ai didi

mysql - 我在将 mysql 数据库(phpmyadmin)连接到 node.js 时收到错误

转载 作者:行者123 更新时间:2023-11-29 17:30:45 26 4
gpt4 key购买 nike

{ 
Error: connect ECONNREFUSED 127.0.0.1:3306
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)
--------------------
at Protocol._enqueue (/home/ubuntu/workspace/proj/node_modules/mysql/lib/protocol/Protocol.js:145:48)
at Protocol.handshake (/home/ubuntu/workspace/proj/node_modules/mysql/lib/protocol/Protocol.js:52:23)
at Connection.connect (/home/ubuntu/workspace/proj/node_modules/mysql/lib/Connection.js:130:18)
at Object.<anonymous> (/home/ubuntu/workspace/proj/app.js:12:4)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Timeout.Module.runMain [as _onTimeout] (module.js:604:10)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3306,
fatal: true }

IDE Screenshot

最佳答案

您的数据库似乎没有在端口 3306 上运行。

尝试找出端口号并添加端口属性,以便您的代码如下所示:

var db = mysql.createConnection({
host: "127.0.0.1",
user: "root",
password: "",
database: "udit1",
port: YOUR_PORT_NUMBER_HERE
});

关于mysql - 我在将 mysql 数据库(phpmyadmin)连接到 node.js 时收到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50680553/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com