chill117 / express-mysql-session

A MySQL session store for the express framework in node
MIT License
313 stars 106 forks source link

Upgrade to mysql2 package #127

Closed nullromo closed 2 years ago

nullromo commented 3 years ago

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.

ccmetz commented 2 years ago

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

chill117 commented 2 years ago

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);
Mistaken-JOKESTER commented 2 years ago

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

ccmetz commented 2 years ago

@chill117, thanks for the example!

Mistaken-JOKESTER commented 2 years ago

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

chill117 commented 2 years ago

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.

nullromo commented 2 years ago

Thanks for the solution.