Unable to Regenerate MySQL DB password
samueljh1
PROOP

a month ago

I have tried multiple times to regenerate the MySQL DB password via Database -> Config -> Regenerate Password. Once triggered, the database redeploys and the environment variables update in the Railway console, however when connecting to the DB, the new password does not work and the original one still works.

We need this fixed ASAP.

Thanks in advance.

Solved$20 Bounty

27 Replies

Try this:

  1. SSH into your MySQL service (Right click the service and Copy SSH Command) (You'll need Railway CLI installed for this to work)
  2. In the terminal, paste the SSH command and run mysql -u root -p
  3. Enter the current working password
  4. Run the following commands:
ALTER USER 'root'@'localhost' IDENTIFIED BY '';
FLUSH PRIVILEGES;

Where `` is replaced with the new password (From the variable MYSQL_ROOT_PASSWORD


This should reset the MySQL's password to use the newly generated password in the variables tab.


samueljh1
PROOP

a month ago

Thanks - let me give this a try


samueljh1
PROOP

a month ago

@pepper very odd.. so when running mysql -u root -p, it only acepts the new password, but when connecting externally, this password doesn't work and I can only use the original password


  • External connection requires old password
  • Root access via SSH uses new password
  • Current Railway variable is new password
  • Railway's database UI doesn't connect

Is this correct?


samueljh1
PROOP

a month ago

All correct apart from bottom - railway's database UI connects fine


  • External connection requires old password
  • Root access via SSH uses new password
  • Current Railway variable is new password
  • Railway's database UI does connect -# Oops accidentally deleted old msg

samueljh1
PROOP

a month ago

Correct


samueljh1
PROOP

a month ago

I ran the alter user command just now, didn't expect anything to change, and I was correct


samueljh1
PROOP

a month ago

So it seems the proxy has its own auth system maybe, once its happy with the password received externally it just tunnels the connection thru Railway?


samueljh1
PROOP

a month ago

That seems like the only logical explanation to the password mismatch


samueljh1
PROOP

a month ago

@Brody any thoughts?


a month ago

No need to ping, pepper is handling this.


samueljh1
PROOP

a month ago

you reacted


Try running the alter command but instead of localhost, put %.


samueljh1
PROOP

a month ago

@pepper thanks, but this made no difference also


Sorry, but just to clarify, you ran ALTER USER 'root'@'%' IDENTIFIED BY '';, yes? Where `` has the new password.


samueljh1
PROOP

a month ago

yes that's correct


samueljh1
PROOP

a month ago

and also flushed


samueljh1
PROOP

a month ago

@pepper nevermind, working now!


Good to know.


samueljh1
PROOP

a month ago

I had to fully disconnect my client to re-trigger auth


samueljh1
PROOP

a month ago

Looks good now, thanks very much for the help


Almost scared me haha, spun up a test MySQL instance just to test the ALTER commands and it was working on my end.


No worries.


Status changed to Solved brody about 1 month ago


a month ago

We have also fixed this, so you won't have to manually run SQL going forward.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...