简体   繁体   中英

Connecting PHP to Cloud MYSQL Google Apps

I am trying to connect my google app to a google cloud SQL instance, I have followed all the documentation and have read every page here I can find but no luck so far.

I am connecting using this -

<?php
$host = ":/cloudsql/<your-project-id>:<your-instance-name>";
$user = "root";
$password = " ";
$datbase = "cloudbooks";
mysql_connect($host,$user,$password);
mysql_select_db($datbase);
?>

The error I am getting is

Unable to find the socket transport "unix" - did you forget to enable it when you configured PHP?

Any help would be amazing!

First thing's last.. Do not use mysql_ instead use mysqli_ for all the reasons on this you can check this : Stackoverflow mysql_

Moving on from that, there is no reason you should think of connecting to a MySQL server any different just because of how its hosted. Cloud is a wonderfull Buzz word.. But its nothing new, its still just a host.

So you can use the following in your connection construction.

$host = "hostname // IP";
$user = "username";
$password = "password";
$datbase = "your_database";

There is actually some documentation also on this : google 'cloud' MySQL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM