Location: Asia Pacific, Cyberspace, in the Dark Dystopia
Posts: 19,118
Thanks Given: 2,351
Thanked 3,359 Times in 1,878 Posts
Node.js and mysql - ER_ACCESS_DENIED_ERROR
This problem has been killing me all day, and I cannot solve it.
Basically, I am using node.js with the mysql module and it will not connect to the database.
Here is the JS code snippet in node.js:
Code:
app.get("/test", function(req, res) {
var mysql = require("mysql");
var con = mysql.createConnection({
host: "127.0.0.1",
user: "node",
password: "myPassword",
database: "myDatabase",
port: 3306
});
console.log("Connection Object Created");
con.connect(function(error1) {
if (error1) {
console.log(error1);
return;
} else {
console.log("Connected1");
}
});
});
I have checked the grants and permissions and all is just fine in MySQL and I can easily connect to the DB manually from the command line using:
Code:
mysql -u node -p myDatabase
After hours and hours of this, it always give error:
Code:
Connection Object Created
{ Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'node'@'127.0.0.1' (using password: YES)
at Handshake.Sequence._packetToError (/var/node/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Handshake.ErrorPacket (/var/node/node_modules/mysql/lib/protocol/sequences/Handshake.js:124:18)
at Protocol._parsePacket (/var/node/node_modules/mysql/lib/protocol/Protocol.js:278:23)
at Parser.write (/var/node/node_modules/mysql/lib/protocol/Parser.js:76:12)
at Protocol.write (/var/node/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket.<anonymous> (/var/node/node_modules/mysql/lib/Connection.js:91:28)
at Socket.<anonymous> (/var/node/node_modules/mysql/lib/Connection.js:502:10)
at Socket.emit (events.js:182:13)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
--------------------
at Protocol._enqueue (/var/node/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/var/node/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at Connection.connect (/var/node/node_modules/mysql/lib/Connection.js:118:18)
at /var/node/index.js:27:5
at Layer.handle [as handle_request] (/var/node/node_modules/express/lib/router/layer.js:95:5)
at next (/var/node/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/var/node/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/var/node/node_modules/express/lib/router/layer.js:95:5)
at /var/node/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/var/node/node_modules/express/lib/router/index.js:335:12)
code: 'ER_ACCESS_DENIED_ERROR',
errno: 1045,
sqlMessage:
'Access denied for user \'node\'@\'127.0.0.1\' (using password: YES)',
sqlState: '28000',
fatal: true }
I have Googled and read at least 30 tutorials, watched at least 5 YT videos on node.js and MySQL, and read the docs many time.
I cannot get past this error.
Darn!
Does anyone here use node.js and MySQL ??? If so, please help.
me@myServer:~# mysql -u node -p myDatabase
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
....
mysql> show grants;
+----------------------------------------------------------------------------------------------------------------------+
| Grants for node@localhost |
+----------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'node'@'localhost' IDENTIFIED BY PASSWORD '*7F8BC63ED005891Axxxxxxxx0FBB5A48CB5FFB9' |
+----------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql>
First, I want to thank Neo (LOL) for this post from 2018, Node.js and mysql - ER_ACCESS_DENIED_ERROR
I could not get the Node-RED mysql module to work and searched Google until all my links were purple! I kept getting ER_ACCESS_DENIED_ERROR with the right credentials. Nothing on the web was... (0 Replies)
Hi,
We have HP UX service guard cluster on OS 11.23. Recently 40+ LUNs presented to both nodes by SAN team but I was asked to mount them on only one node. I created required VGs/LVs, created VxFS and mounted all of them and they are working fine. Now client requested those FS on 2nd node as... (4 Replies)
Hi Experts,
I am in need of running a script from one node say node 1 via node 2.
My scheduling tool dont have access to node2 , so i need to invoke the list file from node1 but the script needs to run from node2. because the server to which i am hitting, is having access only for the node... (5 Replies)
After doing a yum install mysql mysql-server on Fedora 14 I wasn't able to fully install the packages correctly. It installed MySQL 5.1. I was getting the following error when running the:
mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)... (3 Replies)
Hi,
Is it possible to have a Solaris cluster of 2 nodes at SITE-A using SVM and creating metaset using say 2 LUNs (on SAN). Then replicating these 2 LUNs to remote site SITE-B via storage based replication and then using these LUNs by importing them as a metaset on a server at SITE-B which is... (0 Replies)
MySQL on my server is down....
I figured out that the mysqld process isn't running. When I try to run it, it says it can't find mysql.sock
Any suggestions?
Here's what I can't do:
can't be root
don't have physical access (do stuff via SSH)
reinstall MySQL (need to keep the current MySQL... (8 Replies)