Cannot connect to the DB
jonnypaes
FREEOP

4 months ago

Hello, I'm having this problem, but I did everything right (I guess). Does anyone know how to fix this?:

(PS. I've tried variables like "${{MYSQL_ROOT_PASSWORD}}" and the actual values, but it didn't work either)

The repo.

https://github.com/jonnypaes/rascunho_hospital

It works normally on local docker. Can anyone help me out?

Error below (To make it easier to other people with the same problem to search:

⁨```

❌ DB connection failed Error: Access denied for user 'root'@'10.186.220.72' (using password: YES)

at Packet.asError (/app/node_modules/mysql2/lib/packets/packet.js:739:17)

at ClientHandshake.execute (/app/node_modules/mysql2/lib/commands/command.js:29:26)

at PoolConnection.handlePacket (/app/node_modules/mysql2/lib/base/connection.js:508:34)

at PacketParser.onPacket (/app/node_modules/mysql2/lib/base/connection.js:93:12)

at PacketParser.executeStart (/app/node_modules/mysql2/lib/packet_parser.js:75:16)

at Socket. (/app/node_modules/mysql2/lib/base/connection.js:100:25)

at Socket.emit (node:events:517:28)

at addChunk (node:internal/streams/readable:368:12)

at readableAddChunk (node:internal/streams/readable:341:9)

at Readable.push (node:internal/streams/readable:278:10) {

code: 'ER_ACCESS_DENIED_ERROR',

errno: 1045,

sqlState: '28000',

sqlMessage: "Access denied for user 'root'@'10.186.220.72' (using password: YES)",

sql: undefined

}

Solved

13 Replies

4 months ago

Can you show how your are referencing the variables? For example, something like this:

DB_HOST="${{MariaDB.MARIADB_HOST}}"
DB_NAME="${{MariaDB.MARIADB_DATABASE}}"
DB_PASSWORD="${{MariaDB.MARIADB_PASSWORD}}"
...

jonnypaes
FREEOP

4 months ago

Something like this:

{

"DB_HOST": "${{MYSQLHOST}}",

"DB_NAME": "${{MYSQLDATABASE}}",

"DB_PASS": "${{MYSQLPASSWORD}}",

"DB_PORT": "${{MYSQLPORT}}",

"DB_USER": "${{MYSQLUSER}}"

}

DB_HOST: mysql.railway.internal - MYSQLHOST

DB_USER: root - MYSQLUSER

DB_PASS: KYfIFhfIkGtjS... - MYSQLPASSWORD

DB_NAME: railway - MYSQLDATABASE

DB_PORT: 3306 - MYSQLPORT


jonnypaes
FREEOP

4 months ago

Tried both, the variables and the constants. The error is the same as in the picture.


4 months ago

Make sure to include the service's name when referencing variables from another service. For example ${{MySQL.MYSQLHOST}}.


4 months ago

There is also an indicator in the dashboard when you are actually referencing variables from another service.

1467226636167414041


jonnypaes
FREEOP

4 months ago

What? How can I make this connection?


jonnypaes
FREEOP

4 months ago

Great tip. Thank you. But I will try this later. Now I'm trying to add the constants, so I can make sure I'm not making anything wrong with the variables


4 months ago

This connection is automatically shown when you have a service referencing a variable from another service.


jonnypaes
FREEOP

4 months ago

The same =/

My variables:

DB_HOST="${{MySQL.MYSQLHOST}}"

DB_NAME="${{MySQL.MYSQLDATABASE}}"

DB_PASS="${{MySQL.MYSQLPASSWORD}}"

DB_PORT="${{MySQL.MYSQLPORT}}"

DB_USER="${{MySQL.MYSQLUSER}}"

1467228946000118065


4 months ago

Hey, I just deployed your backend (root directory set to backend with the source being your public GitHub repository) and seems to work correctly with

DB_HOST="${{MySQL.MYSQLHOST}}"
DB_PORT="${{MySQL.MYSQLPORT}}"
DB_USER="${{MySQL.MYSQLUSER}}"
DB_NAME="${{MySQL.MYSQLDATABASE}}"
DB_PASS="${{MySQL.MYSQLPASSWORD}}"

Do you have any data in your MySQL database? If not, then you can try to deploy another one and move the reference variables to the newly deployed MySQL database.

1467232267624648814


jonnypaes
FREEOP

4 months ago

Weird. I'll try to remove this one and create another one.

To answer your question, no, the database is empty


jonnypaes
FREEOP

4 months ago

Just an update.

Tried to delete the database and create a new one, it didn't work.

Tried to delete the backend and create a new one, it worked.

I don't know why, because I made my settings exactly as the default one.

Thank you very much, @uxuz.


4 months ago

Glad that you have solved the issue, I'll mark this thread as solved <:salute:1137099685417451530>


Status changed to Solved uxuz 4 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...