Changing MYSQL_ROOT_PASSWORD and other MYSQL variables

sayilTRIAL

a year ago

My MYSQLROOTPASSWORD was compromised. I tried changing the value in the password in my console, but even after saving and redeploying the new value, the connection still expects my original password.

How do I change this variable?

Similarly, if I wanted to create a non-root user to access my DB, how would I go about doing this? Changing MYSQLUSER from "root" to "test" did not work.

Solved

6 Replies

a year ago

When you say connection, you mean the DB UI?

Railway has no idea what your DB password will be if you change it so you can create and modify as many users as you want but that will mean that the built in UI won't work nor will use that created user.


sayilTRIAL

a year ago

Database Connection

We are unable to connect to the database over the public network.

Can you connect using this command?

mysql -hroundhouse.proxy.rlwy.net -uroot -p --port 32174 --protocol=TCP railway

The command works with my old password, but does not work with the updated variable password I provided. I need some way to update the DB password. It looks like I may need to do this through a remote connection + CLI since I don't see anywhere in the UI to update it.


a year ago

Correct, you would need to connect to the database with mysql or another database client like dbgate and run the applicable queries to update your password, the password service variable is only used to create the initial password.


sayilTRIAL

a year ago

Thanks for confirming. Sorry if this is a noob question, but I tried altering the password and the action seems restricted:

mysql> ALTER USER 'root'@'roundhouse.proxy.rlwy.net' IDENTIFIED BY 'newpassword';
ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'roundhouse.proxy.rlwy.net'

Is railway restricting the ability to perform this command? Is there any workaround?


a year ago

Railway does not restrict any database actions, they don't have any mechanisms in place that would allow them to do that.


sayilTRIAL

a year ago

Ok, thanks for the input.

My solution was as follows:

mysql> ALTER USER 'root'@'%' IDENTIFIED BY 'newpassword';
mysql> flush privileges;

please note I also ran ALTER USER 'root'@'localhost' but it was not sufficient to update the password.

Thanks for the feedback everyone.


Status changed to Solved railway[bot] about 1 year ago