I have a api that i can run perfectly local on my local machine. It uses msql here is what i have done:
Local:
./enviroments/development/database.json
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "strapi-hook-bookshelf",
"settings": {
"client": "mysql",
"host": "127.0.0.1",
"srv": false,
"port": 3306,
"database": "[REDACTED]",
"username": "[REDACTED]",
"password": "[REDACTED]"
},
"options": {
"ssl": false
}
}
}
}
./enviroments/development/server.json
{
"host": "localhost",
"port": 1337,
"proxy": {
"enabled": false
},
"autoReload": {
"enabled": true
},
"cron": {
"enabled": false
},
"admin": {
"autoOpen": true
}
}
Then i started MAMP up and did an import of the database in phpmyadmin. Perfect everything works.
Now i would like to make it live. So i am using Google Cloud. I have create a msql instance on google cloud platform I have created a database "test"
My question is what should my database.json look like now?
I have tried
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "REDACTED",
"settings": {
"client": "mysql",
"host": "Public IP address i found on googleCloud platform",
have also tried /cloudsql/[REDACTED]
i have tried to put in
"socketPath": "/cloudsql/${process.env.INSTANCE_CONNECTION_NAME}"
"srv": false,
"port": 3306,
// dont know what the port should be
"database": "test",
"username": "REDACTED",
"password": "REDACTED"
},
"options": {
"ssl": false
}
}
}
}
I have tried setting up a app.yaml file. The closes i got it to working was when i deployed it it said server err 500. In all the other cases it just fails.
Can anyone please help me with the correct setup as i dont know what im doing Want to learn how to do this and i have spent all day already:( and got nowhere
I have now tried this. This is my app.staging.yaml
runtime: nodejs10
service: strapi
env_variables:
NODE_ENV: staging
MYSQL_USERNAME: REDACTED
MYSQL_PASSWORD: REDACTED
MYSQL_DATABASE: test
INSTANCE_CONNECTION_NAME: REDACTED"
beta_settings:
cloud_sql_instances: "REDACTED"
And my config/staging/databse.json looks like this
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "strapi-hook-bookshelf",
"settings": {
"client": "mysql",
"host": "${process.env.MYSQL_HOST || '127.0.0.1'}",
"port": "${process.env.MYSQL_PORT || '3306'}",
"database": "${process.env.MYSQL_DATABASE}",
"username": "${process.env.MYSQL_USERNAME}",
"password": "${process.env.MYSQL_PASSWORD}",
"socketPath": "/cloudsql/${process.env.INSTANCE_CONNECTION_NAME}"
},
"options": {}
}
}
}
Deployed but when i visit the link it says
Error: Server Error The server encountered an error and could not complete your request. Please try again in 30 seconds.
"NodeJS" could be anything, as INSTANCE_CONNECTION_NAME
App Engine Standard .
You probably have to create a user and configure access.
See Connecting from an external application using the proxy .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.