errno: -61,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3000,
fatal: true
I am using Mac OS and VS Code to connect to my local server. I have connected mysql workbench to VSCode as well and it is working fine. But when I try to connect it with my program it is not working. I changed the hostname from ‘localhost’ to ‘127.0.0.1’ as well still no luck. Also, I changed my port from 3306 to 3000 as it was not connecting and I got the following error
code: 'ER_ACCESS_DENIED_ERROR',
errno: 1045,
sqlMessage: "Access denied for user 'usersql'@'localhost' (using password: YES)",
sqlState: '28000',
fatal: true
My code:
const { createPool } = require('mysql')
const pool = createPool({
host: "127.0.0.1",
user: "usersql",
password: "password123",
database: "userdb",
connectionLimit: 10,
port: 3000
})
pool.query(`select * from userdb.New_Customer`, function(err, result, fields) {
if (err) {
return console.log(err);
}
return console.log(result);
})