Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with changeUser() #3350

Open
parth-b297 opened this issue Jan 24, 2025 · 1 comment
Open

issue with changeUser() #3350

parth-b297 opened this issue Jan 24, 2025 · 1 comment

Comments

@parth-b297
Copy link

I have this service. I recently updated mysql2 version from 2.3.3 to 3.12.0
The db in the production environment is mysql v 5.7.26
eversince then i have problems with changeUser().

lets say that i create a pool

    const pool = mysql.createPool({
      host: hostForReadWrite,
      port: portForReadWrite,
      user: username,
      password: password,
      waitForConnections: true,
      connectionLimit: poolSize,
      debug: true,
      database: dbname
    });
    const promisePool = pool.promise();
    global.proxyConnectionPool = promisePool;
const connection = await global.proxyConnectionPool.getConnection();

the connection works flawlessly

but when i try to change user (the actual reason for this is to switch to and fro between different dbs)

          await connection.changeUser({
            user: username,
            password: password,
            database: dbName
          });

i keep on getting this error

Error: Access denied for user 'username'@'ip' (using password: NO)
    at PromisePoolConnection.changeUser (d:\workspace\node_modules\mysql2\lib\promise\connection.js:160:22)
    at Object.getProxyNodeConnection (d:\workspace\src\crons\setup-sql-connection.js:18:28)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async test (d:\workspace\src\crons\test.js:21:18) {
  code: 'ER_ACCESS_DENIED_ERROR',
  errno: 1045,
  sqlState: '28000',
  sqlMessage: "Access denied for user 'username'@'ip' (using password: NO)"
}

the exact same code used to work fine with mysql2 v 2.3.3

@sidorares @iarna @sushantdhiman @Dieken @wellwelwel

@sidorares
Copy link
Owner

Hi @parth-b297 would you be able to create self contained repro example / repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants