Skip to content
subject:%20Lost%20MySQL%20root%20password%20%E2%80%94%20need%20reset%20without%20data%20loss
kaoston
OP

4 months 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: [email protected]

•	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.

Solved$20 Bounty

Pinned Solution

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

1 Reply

Railway
BOT

4 months 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 • 4 months 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

Status changed to Solved 0x5b62656e5d • 27 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...