I have a discord bot that has been connecting to my database as follows:
var con_database = mysql.createConnection({
host: "localhost",
user: "root",
password: "mypass",
database: "cordtrax"
});
It has been connecting flawlessly for days now, but suddenly when I start my bot with nodemon, I get the following error:
{ Error: connect ECONNREFUSED 127.0.0.1:3306
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)
--------------------
at Protocol._enqueue (C:\Users\markm\Documents\Projects\bot\node_modules\mysql\lib\protocol\Protocol.js:144:48)
at Protocol.handshake (C:\Users\markm\Documents\Projects\bot\node_modules\mysql\lib\protocol\Protocol.js:51:23)
at Connection.connect (C:\Users\markm\Documents\Projects\bot\node_modules\mysql\lib\Connection.js:118:18)
at Object.<anonymous> (C:\Users\markm\Documents\Projects\bot\bot.js:52:14)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Function.Module.runMain (module.js:694:10)
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3306,
fatal: true }
The same error occurs when starting the bot using regular node. When I try to connect through my mySQL 8.0 command line client, the client closes instantly after inputting my password. When I try and connect through the command line using mysql -h localhost I get the following error:
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
Every guide I have seen so far recommends going to services and starting the mySQL service manually. When I try this, I get the pop up message saying the service has started and stopped.