user3593987
user3593987

Reputation: 11

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 ?

Upvotes: 1

Views: 1701

Answers (2)

Yao Li
Yao Li

Reputation: 2286

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');

Upvotes: 1

ALamp
ALamp

Reputation: 301

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/

Upvotes: 2

Related Questions