PHP 5.2 based app unable to connect to Google Cloud SQL

252 Views Asked by At

We have a PHP 5.2 based app which we migrated to GCE, and encountered the problem where the Mysqli client does not work.

We used Atomic Archive repo to install PHP 5.2 on GCE 6 CentOS 6: http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/

and also installed the provided Mysql client: mysql-5.5.40-26.el6.art.x86_64.rpm

Following testing, the application fails with following error: Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2003): Can't connect to MySQL server on XXX.XXX.XXX.XXX

While the command line mysql client works just fine.

While looking at the mysqli.so PHP extension, we noticed it uses the oldest available MySQL library: /usr/lib64/mysql/libmysqlclient.so.16

Any chance that this library doesn't work with Google Cloud SQL?

1

There are 1 best solutions below

1
On BEST ANSWER

This is how I connect from my php:

$conn = mysqli_connect("<IP>", "<username>", "<password>","database") or die ("Error" . mysqli_error($conn));