Connecting to the database using MySQL Workbench

jcpfjoao1HOBBY

5 months ago

Hello,

I am unable to connect to the database using MySQL Workbench.

One of the error messages is "Failed to connect to mysql at 127.0.0.1:3306 with user root".

Where can I find guidance on how to make this connection correctly?

Solved

10 Replies

jcpfjoao1HOBBY

5 months ago

Help!


5 months ago

127.0.0.1:3306 is a loopback, if you want to connect to the database on Railway then you need to use the host and port along with the credentials of the database you have deployed to Railway.


jcpfjoao1HOBBY

5 months ago

Even though I'm using data from the mysql.railway.internal DB, I'm still unable to connect. Which items exactly should I use from the variable list?


brody

127.0.0.1:3306 is a loopback, if you want to connect to the database on Railway then you need to use the host and port along with the credentials of the database you have deployed to Railway.

jcpfjoao1HOBBY

5 months ago

Even though I'm using data from the mysql.railway.internal DB, I'm still unable to connect. Which items exactly should I use from the variable list?


5 months ago

you need to use the public host and port from the service settings under public networking.

https://docs.railway.com/overview/the-basics#service-settings


brody

you need to use the public host and port from the service settings under public networking.https://docs.railway.com/overview/the-basics#service-settings

jcpfjoao1HOBBY

5 months ago

Strangely, it's not working.

If I use "MYSQLHOST" as "mysql.railway.internal" the error message is "Unable to connect to mysql.railway.internal:3306". If I use "MYSQL_URL" as "mysql://root:oleJuELIRUlOVtxmGmopWDqBmpiXZCdR@mysql.railway.internal:3306/railway" the error message is "Invalid hostname URL.".


5 months ago

Per my previous message, you need to use the public host and port.


brody

Per my previous message, you need to use the public host and port.

jcpfjoao1HOBBY

5 months ago

I believe I am using the correct references as marked "in red" in the attached image.

Wouldn't these be it?

Attachments


5 months ago

No, those are the private host and port variables.


brody

you need to use the public host and port from the service settings under public networking.https://docs.railway.com/overview/the-basics#service-settings

5 months ago

Please see my previous message.