简体   繁体   中英

php connection error to cloud sql on google app engine

php app on google app engine talking to cloud sql throwing error when deployed and run on app

engine.PHP Warning: mysqli::mysqli(): (HY000/2002): Unknown error 4294967295

The same php code runs fine on my laptop and connects to the cloud sql DB fine. Why could that be the case ?

Please make sure that you have the following set up correctly:

1.) You have listed your Google App Engine Application as an Authorized App Engine Application for your Cloud SQL instance. You can do this by going to your instance, clicking "Access Control", and adding your application ID.

2.) You are accessing your Cloud SQL database in the correct way. For example, via mysqli:

$sql = new mysqli(null, 'db-username', '',
'database-name', null, '/cloudsql/appengine-project-id:cloud-sql-instance-name' );

IMPORTANT Note that if you are connecting from the App Engine Application, you should not enter a password IMPORTANT

More info on step 2 at: https://developers.google.com/appengine/docs/php/cloud-sql/

It's recommended to use the unix socket for CloudSQL, specify the default socket in php.ini.

mysqli.default_socket= '/cloudsql/CONNECTION_NAME'

$db = mysqli_connect('localhost', 'USER', 'PASSWORD', 'DB');

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