chill117 / express-mysql-session

A MySQL session store for the express framework in node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Upgrade to mysql2 package

nullromo opened this issue · comments

I got this error while trying to use this package: Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client. I got the same error when using mysql normally in node, and this stack overflow answer led me to try out mysql2 instead. It worked.

I would recommend swapping the mysql dependency in this package over to the mysql2 package instead. That way, issues like this one will be resolved easily.

For now, I am using the less-secure option of changing the authentication method.

I second this. I'm a little hesitant to downgrade the authentication method in order to get this library to work with my database.

You can use mysql2 with express-mysql-session without any changes to this module:

var mysql2 = require('mysql2/promise');
var session = require('express-session');
var MySQLStore = require('express-mysql-session')(session);

var options = {
    host: 'localhost',
    port: 3306,
    user: 'db_user',
    password: 'password',
    database: 'db_name'
};

var connection = mysql2.createPool(options);
var sessionStore = new MySQLStore({}/* session store options */, connection);

Hello I have fixes this issue on my local machine can, can I fix this in your repo Please

@chill117, thanks for the example!

instead of doing this why don't you upgrade to mysql2 in your package you just have change one line only.

instead of doing this why don't you upgrade to mysql2 in your package you just have change one line only.

I don't have time at the moment to properly vet the mysql2 module. So I would not feel comfortable adding it as a direct dependency.

Thanks for the solution.