gae sqlstate上的pdo[hy000][2002]

wn9m85ua  于 2021-06-25  发布在  Mysql
关注(0)|答案(1)|浏览(436)

我有一个gae php应用程序,它使用pdo连接mysql示例。mysql示例托管在不同的gcp项目中。我有一个错误:

SQLSTATE[HY000] [2002] Unable to find the socket transport \"unix\" - 
did you forget to enable it when you configured PHP?

这是pdo代码:


# GAE

$this->database = new PDO('mysql:unix_socket=<SQL_INSTANCE_NAME>;dbname=<DB_NAME>', <USER>, <PASSWORD>);
$this->database->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->database->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);

是否可以将gae php应用程序连接到其他项目的mysql示例?

gxwragnw

gxwragnw1#

固定的!!!我有这个密码

$this->database = new PDO('mysql:unix_socket=<SQL_INSTANCE_NAME>;dbname=<DB_NAME>', <USER>, <PASSWORD>);

当时是: :/cloudsql/<PROJECT>:<REGION>:<DB_NAME> 解决办法是去掉结肠!!!
所以这是正确的dsn:

$this->database = new PDO('mysql:unix_socket=/cloudsql/<PROJECT>:<REGION>:<DB_NAME>;dbname=<DB_NAME>', <USER>, <PASSWORD>);

相关问题