Reputation: 11
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
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
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