Adonisjs Migration - MySQL using password no

Trying to deploy an app on railway with adonisjs and a MySQL database, I can get the web app running correctly, but trying to connect to the db errors out.
> node ace migration:run --force && node build/server.js
Error: Access denied for user 'root'@'35.197.18.138' (using password: NO)
at Packet.asError (/app/node_modules/mysql2/lib/packets/packet.js:728:17)
at ClientHandshake.execute (/app/node_modules/mysql2/lib/commands/command.js:29:26)
at Connection.handlePacket (/app/node_modules/mysql2/lib/connection.js:478:34)
at PacketParser.onPacket (/app/node_modules/mysql2/lib/connection.js:97:12)
at PacketParser.executeStart (/app/node_modules/mysql2/lib/packet_parser.js:75:16)
at Socket.<anonymous> (/app/node_modules/mysql2/lib/connection.js:104:25)
at Socket.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
> node ace migration:run --force && node build/server.js
Error: Access denied for user 'root'@'35.197.18.138' (using password: NO)
at Packet.asError (/app/node_modules/mysql2/lib/packets/packet.js:728:17)
at ClientHandshake.execute (/app/node_modules/mysql2/lib/commands/command.js:29:26)
at Connection.handlePacket (/app/node_modules/mysql2/lib/connection.js:478:34)
at PacketParser.onPacket (/app/node_modules/mysql2/lib/connection.js:97:12)
at PacketParser.executeStart (/app/node_modules/mysql2/lib/packet_parser.js:75:16)
at Socket.<anonymous> (/app/node_modules/mysql2/lib/connection.js:104:25)
at Socket.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
I think I've narrowed down the error to being related to the adonisjs mysql driver, not passing in the correct env variables, but will need to troubleshoot more. Wanted to see if anyone else had experienced this error
No description
14 Replies
Percy
Percy•14mo ago
Project ID: N/A
Brody
Brody•14mo ago
can you show a screenshot of your service variables @elquesobandito ^^
El Queso Bandito
El Queso Bandito•14mo ago
Hey @Brody sorry, just seeing this now I can share the variables shortly I also just tested using PG instead of MySQL for a database and the deployment / migration went off without a hitch so it's definitely something in how Adonis (or Knex as the database service layer) is handling the MySQL connection Here's all the variables I have for the working PgSQL version, its just a testing deploy so nothing in here that really needs to be kept secret
APP_KEY=<APP_KEY>
CACHE_VIEWS=false
DRIVE_DISK=local
GITHUB_CLIENT_ID=clientId
GITHUB_CLIENT_SECRET=clientSecret
GOOGLE_CLIENT_ID=clientId
GOOGLE_CLIENT_SECRET=clientSecret
HOST=0.0.0.0
MAILHOG_DASHBOARD_PORT=8026
MAILHOG_PORT=1026
DB_CONNECTION=pg
PG_HOST=${{Postgres.PGHOST}}
PG_PORT=${{Postgres.PGPORT}}
PG_USER=${{Postgres.PGUSER}}
PG_PASSWORD=${{Postgres.PGPASSWORD}}
PG_DB_NAME=${{Postgres.PGDATABASE}}
PORT=3333
REDIS_PORT=6379
SESSION_DRIVER=cookie
APP_KEY=<APP_KEY>
CACHE_VIEWS=false
DRIVE_DISK=local
GITHUB_CLIENT_ID=clientId
GITHUB_CLIENT_SECRET=clientSecret
GOOGLE_CLIENT_ID=clientId
GOOGLE_CLIENT_SECRET=clientSecret
HOST=0.0.0.0
MAILHOG_DASHBOARD_PORT=8026
MAILHOG_PORT=1026
DB_CONNECTION=pg
PG_HOST=${{Postgres.PGHOST}}
PG_PORT=${{Postgres.PGPORT}}
PG_USER=${{Postgres.PGUSER}}
PG_PASSWORD=${{Postgres.PGPASSWORD}}
PG_DB_NAME=${{Postgres.PGDATABASE}}
PORT=3333
REDIS_PORT=6379
SESSION_DRIVER=cookie
The MySQL deploy was the same just with DB_CONNECTION=pg and then MYSQL_USER=${{MySQL.MYSQLUSER}} for that service
Brody
Brody•14mo ago
well I'm interested in seeing the variables for the service that isn't working not one that is working lol screenshot of the service variables with everything that's not sensitive in the slightest shown please
El Queso Bandito
El Queso Bandito•14mo ago
Sorry, I get what you're saying but I already swapped out the MySQL service for PG so I'll have to go back recreate it. When I have a couple minutes I'll just spin up a fresh adonis web project with MySQL and commit it to a public repo
Brody
Brody•14mo ago
well hold on, if you are happy with postgres so am i
El Queso Bandito
El Queso Bandito•14mo ago
For now I can confirm that there's some sort of issue using the base config MySQL in adonisjs and that using postgresql resolves the issue
Brody
Brody•14mo ago
postgres uses significantly less memory than mysql, so i am more than happy to say the solution is to simply use postgres but more likely than not, it was probably just a misconfiguration in the service variables that accounts for most database connection issue i have seen
El Queso Bandito
El Queso Bandito•14mo ago
yeah, it's definitely possible, I'll still spin up a new project just to test and out and see cause now I'm more curious myself haha
Brody
Brody•14mo ago
fair enough, id still be down to help out though
El Queso Bandito
El Queso Bandito•14mo ago
sounds good, I'll start it now and post a link to the public repo The other thing is that Adonisjs is about to release a new major version, v6, but I don't have access to that code base yet, so not sure if the issue (if it is an issue and not just wrong env variables) will still exist
Brody
Brody•14mo ago
wait and see!
El Queso Bandito
El Queso Bandito•14mo ago
wait, I just remembered I had a copy of the original env config from when I was testing it out too,
MYSQL_DB_NAME=${{MySQL-a6fb4791-c084-4500-b3f3-e2f7e268b948.MYSQLDATABASE}}
MYSQL_HOST=${{MySQL-a6fb4791-c084-4500-b3f3-e2f7e268b948.MYSQLHOST}}
MYSQL_PASSWORD=${{MySQL-a6fb4791-c084-4500-b3f3-e2f7e268b948.PASSWORD}}
MYSQL_PORT=${{MySQL-a6fb4791-c084-4500-b3f3-e2f7e268b948.MYSQLPORT}}
MYSQL_USER=${{MySQL-a6fb4791-c084-4500-b3f3-e2f7e268b948.MYSQLUSER}}
MYSQL_DB_NAME=${{MySQL-a6fb4791-c084-4500-b3f3-e2f7e268b948.MYSQLDATABASE}}
MYSQL_HOST=${{MySQL-a6fb4791-c084-4500-b3f3-e2f7e268b948.MYSQLHOST}}
MYSQL_PASSWORD=${{MySQL-a6fb4791-c084-4500-b3f3-e2f7e268b948.PASSWORD}}
MYSQL_PORT=${{MySQL-a6fb4791-c084-4500-b3f3-e2f7e268b948.MYSQLPORT}}
MYSQL_USER=${{MySQL-a6fb4791-c084-4500-b3f3-e2f7e268b948.MYSQLUSER}}
aaaaaaaaand it looks like .PASSWORD is missing the .MYSQL infront of it
Brody
Brody•14mo ago
there you go 🙂
Want results from more Discord servers?
Add your server