2017-10-17 50 views
0
/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Parser.js:80 
     throw err; // Rethrow non-MySQL errors 
     ^

Error: ER_ACCESS_DENIED_ERROR: Access denied for user ''@'localhost' (using password: YES) 
    at Handshake.Sequence._packetToError (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/sequences/Sequence.js:52:14) 
    at Handshake.ErrorPacket (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/sequences/Handshake.js:130:18) 
    at Protocol._parsePacket (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Protocol.js:279:23) 
    at Parser.write (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Parser.js:76:12) 
    at Protocol.write (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Protocol.js:39:16) 
    at Socket.<anonymous> (/home/gayathri/jsonhbs/node_modules/mysql/lib/Connection.js:103:28) 
    at emitOne (events.js:96:13) 
    at Socket.emit (events.js:188:7) 
    at readableAddChunk (_stream_readable.js:176:18) 
    at Socket.Readable.push (_stream_readable.js:134:10) 
    -------------------- 
    at Protocol._enqueue (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Protocol.js:145:48) 
    at Protocol.handshake (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Protocol.js:52:23) 
    at Connection.connect (/home/gayathri/jsonhbs/node_modules/mysql/lib/Connection.js:130:18) 
    at Object.<anonymous> (/home/gayathri/jsonhbs/db1.js:8:12) 
    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 Module.runMain (module.js:604:10) 
+1

你嘗試訪問使用MySQL客戶端(linux命令)用相同的用戶名和密碼,MySQL服務器?似乎是一個授權錯誤 – Pavan

+0

如果我沒有弄錯,你甚至不會傳遞一個用戶?這確實是一個認證錯誤。 – Ardzii

+0

我可以通過linux命令訪問,是的,我已經通過了一個用戶。這就是爲什麼我很困惑。 –

回答

0

在您的錯誤信息,你可以清楚地看到,你沒有與MySQL連接呼叫發送正確的用戶字段。

確保您發送想要連接的用戶。

你正在使用哪個mysql庫? Felix的節點,MySQL,你必須通過以下對象:

mysql.createConnection({host:"localhost",user:"root",password:"secretpasshere"},function(...){...})

+0

謝謝。我知道了 –

+0

習慣上投票選出正確的答案:S –