prisma: `Error querying the database: Unknown authentication plugin 'mysql_clear_password'.`
Problem
Getting “Error querying the database: Unknown authentication plugin `mysql_clear_password’.” when trying to connect to an AWS RDS proxy (I can connect fine in other clients with proxy and I can connect fine with prisma directly to the database).
Think its because you have to send the password a certain way when using the mysql_clear_password plugin
Suggested solution
I couldn’t find where we make mysql connections in the project (didn’t spend a lot of time looking), but we need add a way to switch auth when making a connection.
mysql2 has the ability to do this with the authPlugins or on the connection config itself as authSwitchHandler. See below which I got from here https://gist.github.com/btbytes/cf1a1e4a90582924833f4d0a15acc1e9
connectionConfig.authSwitchHandler = (data, cb) => {
if (data.pluginName === 'mysql_clear_password') {
// See https://dev.mysql.com/doc/internals/en/clear-text-authentication.html
console.log("pluginName: "+data.pluginName);
let password = token + '\0';
let buffer = Buffer.from(password);
cb(null, password);
}
};
I don’t think there is alternative solution using prisma
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 4
- Comments: 22 (7 by maintainers)
Commits related to this issue
- feat(client): added enable cleartext plugin to mysql docker env variables Closes #10304 — committed to MohamedAkl1/prisma by deleted user a year ago
- feat(client): added enable cleartext plugin to mysql docker env variables Closes #10304 — committed to MohamedAkl1/prisma by MohamedAkl1 a year ago
- feat(client): added enable cleartext plugin to mysql docker env variables Closes #10304 — committed to MohamedAkl1/prisma by MohamedAkl1 a year ago
Is there any updates? I am currently trying to connect to aws rds via iam auth. And I got
I understand
mysql_clear_password
is not supported yet in inner engine of prisma. Maybe the error message is from here. https://github.com/prisma/mysql_async/blob/master/src/conn/mod.rs#L461 https://github.com/prisma/mysql_async/blob/0778dea4c9a9f851ff41753e92208dcdf3824c40/src/error.rs#L145I am searching alternative way to query aws rds via iam auth in prisma.
Via https://dev.mysql.com/doc/refman/8.0/en/mysql-command-options.html#option_mysql_enable-cleartext-plugin it seems that one has to start MySQL with
--enable-cleartext-plugin
, or via https://dev.mysql.com/doc/refman/8.0/en/cleartext-pluggable-authentication.html setting the env varLIBMYSQL_ENABLE_CLEARTEXT_PLUGIN=1
might also be enough. So maybe a change here is enough: https://github.com/prisma/prisma/blob/dcbc3c3b3204650c45ce8cb9c1bfbccd3cb2527c/docker/docker-compose.yml#L59-L64NP, let me create a reproduce dockerfile.
@cmonaghan1 unfortunately I never did. I switched to another framework for my needs that let use an authPlugin in mysql2 (which lets me use clear text auth)
If there is a way in prisma to manually create the connection and also change the authentication then that would solve it I think (I think prisma def supports mysql2 so it should be possible).