I'm totally stumped on what I think is probably something easy. Been searching for days on this with no luck as I learn how to use Cloud SQL. There are lots of examples on app engine, but almost none on the simplicity of connecting a GCP Virtual Machine to GCP Cloud SQL. The instructions from Google don't seem to be complete. Here is what I have:
In the same GCP Project I created a Bitnami LAMP VM. In the same project I've created a CloudSQL Instance with a single database, and two tables. My intent is to experiment with accessing CloudSQL via a PHP script from the VM. (Yes I know I could setup an SQL server on the VM, but my intent here is to learn how to access CloudSQL). Note, everything is in the same GCP project, so from what I can understand I should NOT have to use the SQL proxy.
I've enabled the CloudSQL API in the project as well.
<?php
$DB_NAME = "dwelling_winebot";
$DB_USER = "winebot_reader";
$DB_PASS = "winebot_reader";
$tableName = "wines";
$mysqli = new mysqli(null, $DB_USER, $DB_PASS, $DB_NAME,null, "/cloudsql/web-sites-123456:us-central1:winebot");
... More code below
The error I get in the apache error_log is:
[08-Oct-2018 05:00:24 America/Los_Angeles] PHP Warning: mysqli::__constru
ct(): (HY000/2002): No such file or directory in /opt/bitnami/apache2/htdo
cs/winebot/serverside/inforunner.php on line 25
(Incidentally, line 25 is the $mysqli line and the php filename is inforunner.php that has the php code above )
Notable facts:
Any help would be greatly appreciated.
use the internal IP instead of a socket, which does not exist.
see Connecting MySQL Client from Compute Engine for reference.