【发布时间】:2018-07-23 05:41:36
【问题描述】:
我正在按照说明 here 将 Ghost 用作 NPM 模块,并尝试将 Ghost 设置为生产环境。
我在本地运行 Google 云 sql 代理。当我运行 NODE_ENV=production knex-migrator init --mgpath node_modules/ghost 时,我收到以下错误消息:
NAME: RollbackError
CODE: ER_ACCESS_DENIED_ERROR
MESSAGE: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'cloudsqlproxy~[SOME_IP_ADDRESS]' (using password: NO)
运行knex-migrator init --mgpath node_modules/ghost 工作正常,我可以毫无问题地在本地启动应用程序。只有在我尝试将应用设置为生产时才会遇到问题。
编辑:我可以通过 MySQL Workbench 连接到数据库,使用我在下面的配置中使用的相同凭据
这是我的config.production.json(已删除私人数据):
{
"production": {
"url": "https://MY_PROJECT_ID.appspot.com",
"fileStorage": false,
"mail": {},
"database": {
"client": "mysql",
"connection": {
"socketPath": "/cloudsql/MY_INSTANCE_CONNECTION_NAME",
"user": "USER",
"password": "PASSWORD",
"database": "DATABASE_NAME",
"charset": "utf8"
},
"debug": false
},
"server": {
"host": "0.0.0.0",
"port": "2368"
},
"paths": {
"contentPath": "content/"
}
}
}
还有app.yaml:
runtime: nodejs
env: flex
manual_scaling:
instances: 1
env_variables:
MYSQL_USER: ******
MYSQL_PASSWORD: ******
MYSQL_DATABASE: ******
# e.g. my-awesome-project:us-central1:my-cloud-sql-instance-name
INSTANCE_CONNECTION_NAME: ******
beta_settings:
# The connection name of your instance on its Overview page in the Google
# Cloud Platform Console, or use `YOUR_PROJECT_ID:YOUR_REGION:YOUR_INSTANCE_NAME`
cloud_sql_instances: ******
# Setting to keep gcloud from uploading not required files for deployment
skip_files:
- ^(.*/)?#.*#$
- ^(.*/)?.*~$
- ^(.*/)?.*\.py[co]$
- ^(.*/)?.*/RCS/.*$
- ^(.*/)?\..*$
- ^(.*/)?.*\.ts$
- ^(.*/)?config\.development\.json$
【问题讨论】:
标签: node.js google-cloud-platform google-cloud-sql knex.js ghost