MySQL Flask connection stopped working
ddsna
HOBBYOP

2 years ago

Hi!
I'm getting this error now when connecting to my mysql db after redeploying the standard railway image for an updated mysql version.

sqlalchemy.exc.DatabaseError: (mysql.connector.errors.DatabaseError) 1524 (HY000): Plugin 'mysql_native_password' is not loaded

(Background on this error at: https://sqlalche.me/e/20/4xp6)

It seems my only option was to go through users to switch to a new password security setting as the previous default has removed. When exploring with the workbench I get this error
However, even when running this code I still get the error above.

connection_string = f"mysql+mysqlconnector://pythonapp:{__up_key}@{__url_db}:{__port_db}/{__up_db}"
engine = create_engine(connection_string, pool_recycle=360, echo=True, connect_args={'auth_plugin': 'caching_sha2_password'})

Naturally, all code is sensitivized for sharing.

17 Replies

ddsna
HOBBYOP

2 years ago

f3f3aa54-1f32-4a2a-9e9a-61d26191712d


ddsna
HOBBYOP

2 years ago

Naturally I'd love to upgrade my code's security and the provider closing down on an auth method is a pretty big sign to move into the direction they want us to - but it seems my code won't budge.


2 years ago

append --mysql-native-password=ON to your database's start command


ddsna
HOBBYOP

2 years ago

Attempted but doesn't seem to have an effect


ddsna
HOBBYOP

2 years ago

1249459853798146000


ddsna
HOBBYOP

2 years ago

Also FYI it's marked for complete deprecation so I'm not sure this is a real solution

1249460537259982800


2 years ago

are you sure you did that correctly? it looks like you removed every other flag


ddsna
HOBBYOP

2 years ago

There was no other flag previously, yes


2 years ago

how long ago did you deploy this database


ddsna
HOBBYOP

2 years ago

Well before the redeploy roughly 5 months, but the most recent redeploy that screwed things up was 6 days ago


ddsna
HOBBYOP

2 years ago

The redeploy was meant to rebuild the image with a more recent version of mysql and nothing else.
The deployments are as basic as they come with no modifications on my end.


2 years ago

then I think it's best to pin your service to I think mysql 8.30


2 years ago

yeah it was deprecated in 8.4.0


ddsna
HOBBYOP

2 years ago

I'm thinking about migrating the tables because obviously there's some issues with that as well - since they forced some tabular changes as well that make running servers in lower versions connected to 8.4.0 tables


2 years ago

whatever works best for you!


nunommc
PRO

a year ago

Hi,

The same situation happened to me. I restarted the mysql service for the first time, simply to reduce the resource limits, and the app never worked again.

I tried your suggestion, and it outputs the following on MySQL 9.

```
2025-03-05T08:41:08.127679Z 0 [ERROR] [MY-000067] [Server] unknown variable 'mysql-native-password=ON'.
```

I tried rolling back to a deploy from 2 months ago, and it also didn't address the issue. I'm unsure what could have caused this, when I simply tried to reduce the memory down from 8 GB.


nunommc
PRO

a year ago

This comment on stackoverflow says that they had to remove the volume.. Having that it's not an option on production, what other solutions there are?


Welcome!

Sign in to your Railway account to join the conversation.

Loading...