I'm having a problem to connect my DB cloud sql with php. I've tried every possible way to connect (pdo, mysqli & mysql) none of them worked.
I've put an IPv4 for the could sql instance and authorized the compute engine IP in the allowed networks section. When I'm trying to connect from the compute engine with
mysql --host=cloud_sql_IP --user=my_user --password
it's working and I'm able to see the tables.
On the php side I've put this code:
$db = mysql_connect(<CLOUD_SQL_IPV4>, 'root', '');
if (!$db){
die('Connect Error (' . mysql_error());
}
and I get "Connect Error (Permission denied)"
when I'm trying this way:
$conn = mysql_connect(":/cloudsql/<COMPUTE_INSTANCE>:<DB>", "root", "");
if (!$conn) {
die('Connect Error (' . mysql_error());
}
I'm getting: "Connect Error (No such file or directory"
What else should I do?
Thanks!