第二代Google Cloud SQL-App Engine [英] 2nd generation Google cloud SQL - App Engine

查看:77
本文介绍了第二代Google Cloud SQL-App Engine的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很高兴看到您已经在Beta中推出了第二代云SQL.但是,我发现它尚不适用于GAE项目.您可以估计何时启用此链接吗?由于第一代SQL的速度缓慢,我们正在对花哨的系统进行一些基础设施方面的重大更改,但如果更改不远的话,它将坚持使用云SQL.

Delighted to see that you have rolled out 2nd generation cloud SQL in Beta. However, I see that it is not available yet to GAE projects. Can you estimate when this link will be enabled please? We are making some big infrastructural changes in our fancy system necessitated by the slowness of Generation 1 SQL, but will stick with cloud SQL if the change is not far off.

推荐答案

您现在可以从App Engine应用连接到第二代Google Cloud SQL实例.连接字符串与第一代实例(docs).

You can now connect to second generation Google Cloud SQL instances from App Engine apps. The connection string is slightly different from first generation instances (docs).

  1. 在云控制台中打开您的SQL实例.
  2. 在属性下复制实例连接名称".请注意,这与实例的名称"不同,并且可能采用project:region:instance格式.
  3. 对于授权应用程序,用户界面通常说无"-您仍然可以通过GAE进行连接. 注意:SQL实例和GAE应用程序必须属于同一项目.
    更新:不必位于同一项目中,如果它们不在同一项目中,则需要授予访问权限.参考: https://cloud.google.com/sql/docs/dev-access#gaev1-csqlv2-access
  1. Open your SQL instance in the cloud console.
  2. Under properties copy the "Instance connection name". Note that this is different to the 'name' of your instance and will probably follow the format project:region:instance.
  3. It is normal for the UI to say "None" for authorized applications - you will still be able to connect from GAE. Note: the SQL instance and GAE app must be part of the same project.
    Update: Don't have to be in the same project, you need to grant access if they are not in the same project. Ref: https://cloud.google.com/sql/docs/dev-access#gaev1-csqlv2-access

PHP连接代码示例:

Example PHP connection code:

$con = "mysql:unix_socket=/cloudsql/CONNECTION_STRING_FROM_CONSOLE;dbname=some_db";
$this->db = new pdo($con, "root", "");
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

这篇关于第二代Google Cloud SQL-App Engine的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆