subject:%20Lost%20MySQL%20root%20password%20%E2%80%94%20need%20reset%20without%20data%20loss
kaoston
PROOP

a month ago

Hi Railway team,

I manage a production MySQL service and I lost the root password after a failed password rotation. The database UI panel now shows “Access denied for user ‘root’@‘127.0.0.1’ (using password: YES)” and I can no longer connect to run any SQL.

Details:

	Account email: tons217@gmail.com

	Project: production

	Service: MySQL

The MYSQL_ROOT_PASSWORD variable no longer matches the actual root password inside the database, and redeploying the service did not re-sync it. All my data is still on the volume and I do NOT want to lose it — this is a production database with sensitive user data.

Could you please help me reset the MySQL root password WITHOUT wiping the volume / without data loss, or tell me the safe procedure to regain root access on this managed MySQL service?

Thank you.

$20 Bounty

1 Replies

Railway
BOT

a month ago

This thread has been opened as a public bounty so the community can help solve it. The thread and any further activity are now visible to everyone.

Status changed to Open Railway about 1 month ago


Try this:

  1. Remember the current Custom Start Command
  2. Change the Custom Start Command to docker-entrypoint.sh mysqld --skip-grant-tables --skip-networking and redeploy
  3. Go to the console tab of your MySQL service
  4. In the terminal, run mysql -u root
  5. Run the following commands:
ALTER USER 'root'@'localhost' IDENTIFIED BY '<PASSWD>';
ALTER USER 'root'@'%' IDENTIFIED BY '<PASSWD>';
FLUSH PRIVILEGES;

Where <PASSWD> is replaced with the new password (From the variable MYSQL_ROOT_PASSWORD)

  1. Revert the custom start command and redeploy MySQL
  2. Make sure to restart other services that depend on your MySQL database

Welcome!

Sign in to your Railway account to join the conversation.

Loading...