sidorares / node-mysql2

:zap: fast mysqljs/mysql compatible mysql driver for node.js
https://sidorares.github.io/node-mysql2/
MIT License
3.96k stars 594 forks source link

Server requests authentication using unknown plugin sha256_password #1082

Closed Tino-F closed 4 years ago

Tino-F commented 4 years ago

I'm trying to connect to my DB, but I get the below error message:

Error: Server requests authentication using unknown plugin sha256_password. See TODO: add plugins doco here on how to configure or author authentication plugins.

The code I'm using is as followed:

const mysql = require('mysql2');
const pool = mysql.createPool({
  host: process.env.SQL_HOST,
  user: process.env.SQL_USER,
  port: process.env.SQL_PORT || 3306,
  password: process.env.SQL_PASS,
  database: 'MyDatabase',
  waitForConnections: true,
  connectionLimit: process.env.MAX_SQL_CONNECTIONS || 5,
  queueLimit: 0
});
const promisePool = pool.promise();

"mysql2": "^2.0.2",

sidorares commented 4 years ago

Hi @Tino-F , please read comments below https://github.com/sidorares/node-mysql2/pull/1021#issuecomment-559341452

tldr - sha256_password plugin is currently not supported, it is recommended that you upgrade server to use caching_sha2_password

sidorares commented 4 years ago

( error message is not great though, any help improving is is welcomed )

Tino-F commented 4 years ago

@sidorares Thanks for the quick response

kayjlou commented 3 years ago

Make sure in your .env file you don't have quotations around your actual inputs (on the right side)

InocentumAbhijit commented 3 weeks ago

Make sure in your .env file you don't have quotations around your actual inputs (on the right side)

I missed the .env file, solved 👍