无法使用谷歌应用引擎连接到MySQL数据库

时间:2015-03-01 16:28:51

标签: php mysql google-app-engine pdo cloud

我有一个正在运行的Google App Engine应用程序,数据库已设置且应该正常工作(与开发服务器一起使用),但在部署应用程序时无法连接到数据库。我收到以下错误:

Warning: PDO::__construct(): MySQL server has gone away in /base/data/home/apps/s~helloworldtmb/1.382580389844400668/guestbook.php on line 26 

Warning: PDO::__construct(): Error while reading greeting packet. PID=-1 in /base/data/home/apps/s~helloworldtmb/1.382580389844400668/guestbook.php on line 26 {"outcome":false,"message":"Unable to connect."}

第26行是

 $db = new pdo('mysql:unix_socket=/cloudsql/<helloworldtmb>:<helloworldtmb:helloo>;dbname=guestbook', 'root', 'p');

helloworldtmb是应用程序ID,helloworldtmb:helloo是实例名称。任何想法?

2 个答案:

答案 0 :(得分:0)

从项目ID和Cloud SQL实例名称中删除尖括号

答案 1 :(得分:0)

docs you followed填写模板时,您没有删除<angle brackets>。通常,在编程时,如果您看到里面包含单词的尖括号,如“您的应用程序ID”或“您的数据库名称”,则您需要将尖括号解释为定义字符串所在位置的起点和终点。所以,

/home/<your username>/.ssh/

会变成

/home/anon/.ssh/

并且

curl -X <request method> <url>

会变成

curl -X GET http://v1-dot-api.domain.com/threads/list
相关问题