1
votes

Can't seem to get GAE PHP to connect to Cloud SQL, using mysqli, says: Unable to find the socket transport "unix" - did you forget to enable it when you configured PHP?

I've authorized the app and made sure they're both in the same region i.e US

any ideas would be great, thanks

$mysqli = new mysqli(null, "USERNAME", "PASSWORD", "DATABASE", null,
"/cloudsql/PROJECT_NAME:db2");

when i use :/cloudsql/PROJECT_NAME:db2 it's saying there's error with 'sock'

When i use /cloudsql/PROJECT_NAME:db2 without : it's saying cannot connect to user@localhost

2
a code sample would helpStuart Langley
$mysqli = new mysqli(null, "USERNAME", "PASSWORD", "DATABASE", null, "/cloudsql/PROJECT_NAME:db2");Jason Gorman

2 Answers

3
votes

If you are using default authentication, try using “root” as the username, null as password, and the instance-id listed in the Cloud SQL panel, like so. Example:

$conn = new mysqli(null, "root", null, "<databasename>", null, "/cloudsql/<instance id>”);
0
votes

In case anyone viewing this post and getting the 'Unable to find the socket transport "unix"'(that was me) and is using PDO instead of sqli, here is the proper code.

$db = new pdo("mysql:unix_socket=/cloudsql/$GAE_ProjectName:$location:$dbInstance;dbname=$dbName",$username,$password)

These, /cloudsql/$GAE_ProjectName:$location:$dbInstance, can all be found together and copy pasted from the dashboard of your SQL instance under "Connect to this instance" and then "Instance connection name."

The rest of it is just defining those variables and making sure the passwords are right!