我曾经使用xampp运行mysql,我是否必须运行mysql服务?
我遵循了本教程-> http://mfikri.com/en/blog/nodejs-mysql-crud
我在步骤2中感到困惑
Server is running at port 8000
/home/aziz/Desktop/Myprojects/backend/crud_fikri/crud-nodejs-mysql/index.js:23
if(err) throw err;
^
Error: connect ECONNREFUSED 127.0.0.1:3306
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1136:16)
--------------------
at Protocol._enqueue (/home/aziz/Desktop/Myprojects/backend/crud_fikri/crud-nodejs-mysql/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/home/aziz/Desktop/Myprojects/backend/crud_fikri/crud-nodejs-mysql/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at Connection.connect (/home/aziz/Desktop/Myprojects/backend/crud_fikri/crud-nodejs-mysql/node_modules/mysql/lib/Connection.js:118:18)
at Object.<anonymous> (/home/aziz/Desktop/Myprojects/backend/crud_fikri/crud-nodejs-mysql/index.js:22:6)
at Module._compile (internal/modules/cjs/loader.js:1128:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:983:32)
at Function.Module._load (internal/modules/cjs/loader.js:891:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3306,
fatal: true
}
似乎与您的数据库的连接被拒绝。确保使用正确的数据库帐户,并且该帐户具有特权。
还请确保将数据库中的应用列入白名单。
您需要将以下IP列入白名单:127.0.0.1
和localhost