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

Most upvoted comments

Is there any updates? I am currently trying to connect to aws rds via iam auth. And I got

Error querying the database: Unknown authentication plugin `mysql_clear_password'.

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#L145

I am searching alternative way to query aws rds via iam auth in prisma.

NP, 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).