【问题标题】:Connection issue connecting from PHP App engine instance to a Cloud SQL instance created in another App engine running Java Runtime从 PHP 应用引擎实例连接到在另一个运行 Java 运行时的应用引擎中创建的 Cloud SQL 实例的连接问题
【发布时间】:2014-07-04 16:38:34
【问题描述】:

我在连接到应用引擎(Java 运行时)中托管的 Cloud SQL 实例时遇到问题。连接客户端是托管在另一个 Google 应用引擎实例中的 PHP Web 应用程序。 App 引擎实例是否可以连接到另一个实例中的 Cloud SQL?

基本上,我的设置如下:

  • Google App Engine 1(Java 运行时)
    • 与 Cloud SQL 实例一起安装
    • 托管 Google Endpoints 并连接到此实例上的 Cloud SQL
  • Google App Engine 2(PHP 运行时)
    • PHP 脚本连接到 Google App Engine 1 的 Cloud SQL 实例

问题是我总是在下面出现错误:

Warning: mysqli_connect(): MySQL server has gone away in /base/data/home/apps/s~some-php-web-app-v1/v1.376456666740733344/includes/database.php on line 29 Warning: mysqli_connect(): Error while reading greeting packet. PID=-1

我相信我的连接代码是正确的

public function connect($server = DBHOST, $username = DBUSER, $password = DBPASS,  $database = DBNAME, $socket = DBSOCKET, $port = DBPORT)
{
    $this->link = mysqli_connect($server, $username, $password, $database, $port, $socket) or die(mysqli_error());
}

常量是:

define('DBHOST', null);
define('DBSOCKET','/cloudsql/some-app-v1-test:some-db');
define('DBNAME', 'database_name');
define('DBUSER', 'root');
define('DBPORT', null);
define('DBPASS', null);
define('PROJECT_PATH', "http:someserver.com//");

这可能吗?如果是,我必须设置什么配置才能使其正常工作?

谢谢, 斯蒂芬

【问题讨论】:

    标签: google-app-engine mysqli google-cloud-sql


    【解决方案1】:

    我找到了我的新手问题的答案。点击 Cloud SQL 控制台上的编辑,然后在“授权的 App Engine 应用程序”部分下添加您的谷歌应用实例 ID。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-18
      • 1970-01-01
      • 2016-08-06
      • 2019-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多