Internal/External MySQL Auth Mismatch - NYC Surf Co
ryannieds107
HOBBYOP

5 months ago

Issue: I am receiving ER_ACCESS_DENIED_ERROR (1045) for my root user from both internal (IPv6) and external connections.

Details: I have updated the MYSQLPASSWORD environment variable in the dashboard, but the change has not propagated to the internal MySQL user table. My server is unable to connect despite the variables matching.

Ask: Is there a way I can synchronize my internal MySQL root user password with the current MYSQLPASSWORD variable in my environment or provide a temporary root reset?

Solved$10 Bounty

Pinned Solution

You'll need to run another command for that to work, took a little more debugging in that thread.

Follow this one:

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 '<PASSWD>';
ALTER USER 'root'@'%' IDENTIFIED BY '<PASSWD>';
FLUSH PRIVILEGES;

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

5. Make sure to restart other services that depend on your MySQL database

8 Replies

If you wish to change database credentials, you need to do so through the database tab.

Click on your service, go to the database tab, click Config, then Regenerate Password.

Redeploy after, and you should be able to log in with a new password.


ryannieds107
HOBBYOP

5 months ago

Thanks for the response. Unfortunately, I've already regenerated a password and changed all my variables to match the password multiple times. There seems to be a larger issue at play here.


ryannieds107

Thanks for the response. Unfortunately, I've already regenerated a password and changed all my variables to match the password multiple times. There seems to be a larger issue at play here.

I would recommend using reference variables instead of "actual" variables.

To do this, use the template ${{ Servicename.Variablename }}$

For example, if you wish to use the MySQL password in another service, you would do: ${{ MySQL.MYSQLPASSWORD }}


ryannieds107
HOBBYOP

5 months ago

Thanks, I actually already tried that. I think I'm going to reset MySQL service


iyikuyoro
PRO

2 months ago

I am experiencing the same issue here, and reseting the MySQL service is not an option for me. As reported by @ryannieds107, there seems to be a mismatch between the password displayed in the UI after the regeneration, and the internal password used by the service.


iyikuyoro

I am experiencing the same issue here, and reseting the MySQL service is not an option for me. As reported by @ryannieds107, there seems to be a mismatch between the password displayed in the UI after the regeneration, and the internal password used by the service.

iyikuyoro
PRO

2 months ago


iyikuyoro

Trying: <https://station.railway.com/questions/unable-to-regenerate-my-sql-db-password-e1bdd5af>

You'll need to run another command for that to work, took a little more debugging in that thread.

Follow this one:

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 '<PASSWD>';
ALTER USER 'root'@'%' IDENTIFIED BY '<PASSWD>';
FLUSH PRIVILEGES;

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

5. Make sure to restart other services that depend on your MySQL database


iyikuyoro
PRO

2 months ago

That worked. Still a bit scary to lose access to the database for a bit there. I think this should be documented somewhere.


Status changed to Solved 0x5b62656e5d 2 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...