sidorares / sidorares/node-mysql2

ER_ACCESS_DENIED_ERROR when connecting via mysqlrouter

Open
#2,237 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
4.4k
Forks
680
Avg merge
9h 7m
Merged PRs (30d)
59

Description

Hi,
I have a node.js project using "mysql2", "^3.6.0" and "typeorm", "^0.3.17". Then I have set up mysqlrouter in the same server as recommnded. mysql innodb cluster is set up with 3 nodes.
There is no problem connecting to the cluster when connecting directly to any of the cluster nodes from the node.js project. However when I set the connection to go through mysql router, ER_ACCESS_DENIED_ERROR is thrown.
Even as it fails, I am able to connect via mysqlrouter via mysql console or mysql-shell.
Below is the output of the error:

/home/devops/cd-api/node_modules/mysql2/lib/packets/packet.js:728
    const err = new Error(message);
                ^
Error: Access denied for user 'devops'@'localhost' (using password: YES)
    at Packet.asError (/home/devops/cd-api/node_modules/mysql2/lib/packets/packet.js:728:17)
    at ClientHandshake.execute (/home/devops/cd-api/node_modules/mysql2/lib/commands/command.js:29:26)
    at PoolConnection.handlePacket (/home/devops/cd-api/node_modules/mysql2/lib/connection.js:478:34)
    at PacketParser.onPacket (/home/devops/cd-api/node_modules/mysql2/lib/connection.js:97:12)
    at PacketParser.executeStart (/home/devops/cd-api/node_modules/mysql2/lib/packet_parser.js:75:16)
    at Socket.<anonymous> (/home/devops/cd-api/node_modules/mysql2/lib/connection.js:104:25)
    at Socket.emit (node:events:513:28)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9) {
  code: 'ER_ACCESS_DENIED_ERROR',
  errno: 1045,
  sqlState: '28000',
  sqlMessage: "Access denied for user 'devops'@'localhost' (using password: YES)",
  sql: undefined
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported mysql2 connection through MySQL Router and compare it with a direct cluster connection and the working mysql console or mysql-shell connection. Inspect the mysql2 ClientHandshake and packet error paths named in the stack trace, then document or demonstrate the cause of the access denial and the conditions for a successful connection.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, node.js
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.