R
Railway

✋|help

Adonisjs Migration - MySQL using password no

Eelquesobandito9/8/2023
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)


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
BBrody9/8/2023
can you show a screenshot of your service variables
@elquesobandito ^^
Eelquesobandito9/8/2023
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

The MySQL deploy was the same just with DB_CONNECTION=pg and then MYSQL_USER=${{MySQL.MYSQLUSER}} for that service
BBrody9/8/2023
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
Eelquesobandito9/9/2023
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
BBrody9/9/2023
well hold on, if you are happy with postgres so am i
Eelquesobandito9/9/2023
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
BBrody9/9/2023
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
Eelquesobandito9/9/2023
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
BBrody9/9/2023
fair enough, id still be down to help out though
Eelquesobandito9/9/2023
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
BBrody9/9/2023
wait and see!
Eelquesobandito9/9/2023
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}}
aaaaaaaaand it looks like .PASSWORD is missing the .MYSQL infront of it
BBrody9/9/2023
there you go
🙂

Looking for more? Join the community!

Recommended Posts
GraalVMHi, is it possible to build a graalvm image in nixpacks? https://github.com/railwayapp/nixpacks/issuDebugging issuesIs their someway to get into filesystem so I can debug production errors a0aaa94d-45ad-410c-bcae-31Debugging issuesIs their somehow to get into file system? or the built filesEnabled mlockHi everyone, I'm currently creating a template for the hashicorp vault service (https://developer.hSubscription already existsI can't enable the developer plan, the system returns the message: "Subscription already exists"simple socket server got timeout errorhi i have a simple question if i have a java simple sever (spring boot) and in my app in another porCheck SuitesI'm looking for a feature that could allow to deploy if failed build So I try to use Check Suites bTypeError: fetch failed error without much description in the logsFull error below: TypeError: fetch failed at Object.fetch (/app/node_modules/next/dist/compiled/unRenamed user/organization for GitHub - unsafe?A student organization I work with has a cron job service for our database, and it's linked with ourContainer Failed to StartError Response from Daemonssh tunneling errorWhen trying to deploy a django project the following error occurs "raise ValueError('No password or Paths not working when deployed to railway but works in local environmentCurrently making a vite/typescript/react project that has working route handling locally but does nopgbouncerHey folks, I have a supabase and Nextjs (+ prisma) project deployed in Railway, what's the best optiAccessing files inside the volumewhat's the best way to export build artifacts from one service to another? during build process, a tHow usage-based resource management works ?Hello, how Railway manages resource scaling ? like how are vCPU and RAM scaled up and down automaticHow to dynamically scale the replicas of an APIs deployed via Railway based on demand?I have API service with a certain number of replicas, whats the recommended way to scale the number Laravel application failed to respondI am unsure what is causing the issue but the after deploying my laravel app, it still does not starRailway credits gone??I had $15.46 in credits, and now $5 is gone. I have a single project, and I know for a fact my projeInstalling apt packages for puppeteerHi, im trying to run puppeteer on Railway but am getting an error that it cant find some packages. IIs it possible to set permissions on volumes?Dockerfile is using user id of 1000,and the WORKDIR which they own is /app. A Volume is mounted at /