简体   繁体   English

无法使用Google App Engine连接到Google Cloud MySQL

[英]Unable to Connect to Google Cloud MySQL using Google App Engine

  1. I am trying to follow the steps from Getting Started using Cloud MySQL and PHP however I am still getting the SQL error below. 我试图按照Cloud MySQL和PHP使用入门中的步骤进行操作,但是下面仍然出现SQL错误。

  2. Steps I have done so far, 到目前为止,我已经完成的步骤

    a. 一种。 Created a database in Google Cloud MySQL 在Google Cloud MySQL中建立资料库

    b. b。 Created a user and a password, 创建了用户和密码,

My Connection Settings 我的连接设置

Is there anything I am missing? 我有什么想念的吗?

Make sure to open up the firewall on your Cloud SQL instance to allow your IP address to access it. 确保在Cloud SQL实例上打开防火墙,以允许您的IP地址访问它。 For testing purposes, you can open it for all IP addresses by: 为了进行测试,您可以通过以下方式为所有IP地址打开它:

  1. Navigating to your Database Instance 导航到数据库实例
  2. Clicking 'Edit' 点击“编辑”
  3. Click 'Authorize Networks' 点击“授权网络”
  4. Click 'Add Network' 点击“添加网络”
  5. Type 0.0.0.0/0 to open up your database to all networks. 键入0.0.0.0/0将您的数据库打开到所有网络。

NOTE: You should only use that setting for initial testing as it will open up your instance to connections from any IP address. 注意:您应该只将该设置用于初始测试,因为它将打开您的实例与来自任何IP地址的连接。 Once you verify that's the issue, remove that entry and create an entry for just the IP addresses you'll be connecting from. 确认是问题所在后,请删除该条目,并仅为将要从其连接的IP地址创建一个条目。

From AppEngine Standard Environment you do not need an IP to connect to a First Generation Cloud MySQL instance. AppEngine标准环境中,您不需要IP即可连接到第一代Cloud MySQL实例。 For PDO you can use as DSN: 对于PDO,您可以用作DSN:

mysql:unix_socket=/cloudsql/<your-project-id>:<your-mysql-instance-name>;dbname=<database-name>

Starting from AppEngine Flexible Environment or if you use a Second Generation Cloud MySQL you need to install cloud_sql_proxy - see https://cloud.google.com/appengine/docs/flexible/php/using-cloud-sql and/or https://cloud.google.com/appengine/docs/standard/php/cloud-sql/ AppEngine灵活环境开始,或者如果您使用第二代Cloud MySQL ,则需要安装cloud_sql_proxy-请参阅https://cloud.google.com/appengine/docs/flexible/php/using-cloud-sql和/或https:/ /cloud.google.com/appengine/docs/standard/php/cloud-sql/

If what you really want is to test locally with the Cloud SQL from Google Cloud you will also need the same cloud_sql_proxy . 如果您真正想要的是使用Google Cloud中的Cloud SQL在本地进行测试,则还需要相同的cloud_sql_proxy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM