22 days ago
After creating the database in Railway, I made a mistake and changed the PGPASSWORD and then forgot it. Now I no longer have synchronization with the database and I cannot connect to it from my local machine. I also want to export the database to my local machine as a gzip backup. However, my monthly plan is not paid, so the service has been disabled. What can I do to restore access to my database without recovery PRO plan?
1 Reply
Status changed to Awaiting Railway Response Railway • 22 days ago
22 days ago
This thread has been opened as a bounty so the community can help solve it.
Status changed to Open Railway • 22 days ago
22 days ago
Try this:
- Click into your database service and go to the console tab
- Run this command:
sed -i 's/host all all all scram-sha-256/host all all ::\/0 trust/' /var/lib/postgresql/data/pgdata/pg_hba.conf(This will bypass user authentication) - Redeploy your database
- Console again, and run the command
psql - Run
ALTER USER postgres with password '<PASSWORD>';where<PASSWORD>is the value of the variablePGPASSWORDin your Railway dashboard - Type
exit - Run
sed -i 's/host all all ::\/0 trust/host all all all scram-sha-256/' /var/lib/postgresql/data/pgdata/pg_hba.conf(This will re-enable user authentication) - Redeploy your database
As for the backup, you can run pg_dump in the Console, then download the dump file from the filebrowser under the terminal window.
Also, even with the Free plan, you should be able to start the service, unless you ran out of the free usage credits.