Issue using Strapi template

Hi,

while trying to deploy by using the Strapi I get an error:

[2021-05-30T19:54:05.389Z] error Error: ER_DBACCESS_DENIED_ERROR: Access denied for user 'superuser'@'%' to database 'mysql'
    at Handshake.Sequence._packetToError (/app/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
    at Handshake.ErrorPacket (/app/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
    at Protocol._parsePacket (/app/node_modules/mysql/lib/protocol/Protocol.js:291:23)
    at Parser._parsePacket (/app/node_modules/mysql/lib/protocol/Parser.js:433:10)
    at Parser.write (/app/node_modules/mysql/lib/protocol/Parser.js:43:10)
    at Protocol.write (/app/node_modules/mysql/lib/protocol/Protocol.js:38:16)
    at Socket.<anonymous> (/app/node_modules/mysql/lib/Connection.js:88:28)
    at Socket.<anonymous> (/app/node_modules/mysql/lib/Connection.js:526:10)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at Socket.Readable.push (_stream_readable.js:213:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
    --------------------
    at Protocol._enqueue (/app/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at Protocol.handshake (/app/node_modules/mysql/lib/protocol/Protocol.js:51:23)
    at Connection.connect (/app/node_modules/mysql/lib/Connection.js:116:18)
    at /app/node_modules/knex/lib/dialects/mysql/index.js:68:18
    at new Promise (<anonymous>)
    at Client_MySQL.acquireRawConnection (/app/node_modules/knex/lib/dialects/mysql/index.js:63:12)
    at create (/app/node_modules/knex/lib/client.js:290:39)

I followed the instructions in the readme.md in the created GitHub project and created an /env/production/database.js with the provided code.

Deployment always fails.

Cheers

Hello,
I think there is a mistake when we set db user. I changed it to “root” in your environment variables, it looks to work.

Now the issue looks like you didn’t follow steps 8 and 9 of the read me. Did you init the admin user locally ?

No, i did not init the admin user as I thought that would happen only for the local database…

As far as I remember it also generates scripts used in deployment to set it in mysql.

I did those steps and commited the change that resulted. Now there is an error while deploying again as the env-variable has been reset to “superuser” somehow.

I’ll do some check, but yes, that’s strange.

So, I created a new project and follow each steps of the tutorial and it worked perfectly for me…

Did nothing special here… just followed the steps. Never changed any env-variable or sth. else…

It’s working now :slight_smile: Just changed db username to root.

1 Like

Had another deployment now after adding models to strapi. Changed nothing else…

Env-Variable is ‘superuser’ again.

Do I need to set anything on the .qovery.yml? Looks like this atm:

---
application:
  name: "strapi"
  project: "jf-app"
  organization: "QoveryCommunity"
  publicly_accessible: true
  cpu: "800m"
  ram: "512mb"
  start_timeout: "480s"
  storage:
  - name: "data"
    size: "5GB"
    type: "ssd"
    mount_point: "/srv/app"
databases:
- type: "MYSQL"
  name: "my-sql"
  version: "8"
routers:
- name: "main"
  routes:
  - application_name: "strapi"
    paths:
    - "/*"

Edit:
Changed it by myself… but should really not happen at all…

I’m talking about this to the team in order to fix it. Looks like a bug on our side.

So after investigation, it should be solved in v2. At the moment is to set the db username directly in .env file. Instead of

DATABASE_USERNAME=$QOVERY_DATABASE_MY_SQL_USERNAME

set:

DATABASE_USERNAME=root

Also changed few things in Qovery template to make it work. If it’s not a problem for you, you can create a fresh new project from Strapi template to get all the things fixed.