简体   繁体   中英

Why does my PHP Google app engine not connect to Google cloud sql?

I am trying to connect my Google app engine PHP app to Google cloud sql via unix socket (I assume that is correct so that I don't have to connect to the ip). The connect via IP works but the unix socket does not. Any ideas? It's also weird that when I ssh into the box, I don't see any /cloudsql/ directory. I actually don't see even my index.php on there but the page loads fine, maybe debug mode means something else?

I'm using:

$db = new pdo(
  'mysql:unix_socket=/cloudsql/testproject-xxxxxx:us-central1:library;dbname=books',
  'phpapp',  // username
  'somepw'       // password
);

And get SQLSTATE[HY000] [2002] No such file or directory

我想通了,它是将这一部分添加到app.yaml中:

beta_settings: cloud_sql_instances: "<INSTANCE_CONNECTION_NAME>"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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