3

So, I followed this video: https://www.youtube.com/watch?v=XuLRKMqozwA

My code is exactly as follows:

var mysql = require('mysql');

var con = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: 'password',
    database: 'articles'
});

con.connect();

I typed npm install mysql while in the directory that my file is in.

Then typed node new new is the name of the file.

The error I receive is exactly as follows:

events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED 127.0.0.1:3306
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1104:14)
    --------------------
    at Protocol._enqueue (C:\Test\node_modules\mysql\lib\protocol\Protocol.js:144:48)
    at Protocol.handshake (C:\Test\node_modules\mysql\lib\protocol\Protocol.js:51:23)
    at Connection.connect (C:\Test\node_modules\mysql\lib\Connection.js:118:18)
    at Object.<anonymous> (C:\Test\new.js:10:5)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
Emitted 'error' event at:
    at Connection._handleProtocolError (C:\Test\node_modules\mysql\lib\Connection.js:425:8)
    at Protocol.emit (events.js:189:13)
    at Protocol._delegateError (C:\Test\node_modules\mysql\lib\protocol\Protocol.js:390:10)
    at Handshake.<anonymous> (C:\Test\node_modules\mysql\lib\protocol\Protocol.js:153:12)
    at Handshake.emit (events.js:189:13)
    at Handshake.Sequence.end (C:\Test\node_modules\mysql\lib\protocol\sequences\Sequence.js:78:12)
    at Protocol.handleNetworkError (C:\Test\node_modules\mysql\lib\protocol\Protocol.js:361:14)
    at Connection._handleNetworkError (C:\Test\node_modules\mysql\lib\Connection.js:420:18)
    at Socket.emit (events.js:189:13)
    at emitErrorNT (internal/streams/destroy.js:82:8)

All the other "solutions" to the problem that I could find have not worked for me at all. It is probably something very simple that I am doing wrong because I clearly do not have a lot of experience. Anything will help.

Udhav Sarvaiya
  • 9,380
  • 13
  • 53
  • 64
immabot
  • 41
  • 1
  • 3

0 Answers0