8 months ago
I regenerated password on my MySQL database. Then, after updating the database url env variable on my backend service with the new password, subsequent deployments are crashing with error:
Error: P1000: Authentication failed against database server, the provided database credentials for root are not valid.
Pinned Solution
8 months ago
deleting database and creating a new one solved it. Apparently the way MySQL is containerized, password regeneration doesn't propagate
4 Replies
8 months ago
Hey there! We've found the following might help you get unblocked faster:
- 🧵 Failing to see connected db
- 🧵 Prisma: "Authentication failed against database server"
- 🧵 migration failed error in MySQL
If you find the answer from one of these, please let us know by solving the thread!
8 months ago
Time for the great guide of all time
⠀
Before you do any of this, disable all public access domains. Just in case.
⠀
- Install the Railway CLI. You can do so here: https://docs.railway.com/guides/cli
- Copy the SSH command by right clicking the PostgreSQL service
- Once you're in, type in the following command: (Copy paste this EXACTLY as written.)
sed -i 's/host all all all scram-sha-256/host all all ::\/0 trust/' /var/lib/postgresql/data/pgdata/pg_hba.conf - Redeploy your database.
- Use the SSH command again, and once you're in, type
psql. - Type the following SQL command.
my_passwordshould be replaced with whatever it actually says in your variables tab for your password (Probably under thePGPASSWORDvariable.)ALTER USER postgres with password 'my_password'; - Type
exit - Reset your authentication settings with the following command:
sed -i 's/host all all ::\/0 trust/host all all all scram-sha-256/' /var/lib/postgresql/data/pgdata/pg_hba.conf - Redeploy your database once again. You have now changed the password.
⠀
Let me know if this works!
samgordon
Time for the great guide of all time ⠀ Before you do any of this, disable all public access domains. Just in case. ⠀ 1. Install the Railway CLI. You can do so here: <https://docs.railway.com/guides/cli> 2. Copy the SSH command by right clicking the PostgreSQL service 3. Once you're in, type in the following command: (Copy paste this EXACTLY as written.) `sed -i 's/host all all all scram-sha-256/host all all ::\/0 trust/' /var/lib/postgresql/data/pgdata/pg_hba.conf` 4. Redeploy your database. 5. Use the SSH command again, and once you're in, type `psql`. 6. Type the following SQL command. `my_password` should be replaced with whatever it actually says in your variables tab for your password (Probably under the `PGPASSWORD` variable.) `ALTER USER postgres with password 'my_password';` 7. Type `exit` 8. Reset your authentication settings with the following command: `sed -i 's/host all all ::\/0 trust/host all all all scram-sha-256/' /var/lib/postgresql/data/pgdata/pg_hba.conf` 9. Redeploy your database once again. You have now changed the password. ⠀ Let me know if this works!
8 months ago
do you have handy a flavor of this guide for MySQL instead of Postgre?
8 months ago
deleting database and creating a new one solved it. Apparently the way MySQL is containerized, password regeneration doesn't propagate
Status changed to Solved noahd • 8 months ago