Rectangle 27 0

php App engine fails to connect to Google cloud sql?


When connecting to Cloud SQL from an authorized App Engine application, the password is not required (actually it will fail if you try to connect with password).

Note
Rectangle 27 0

php App engine fails to connect to Google cloud sql?


mysql> SELECT user,host,password FROM mysql.user;
+-------+-----------+-------------------------------------------+
| user  | host      | password                                  |
+-------+-----------+-------------------------------------------+
| root  | localhost |                                           |
| root  | 127.0.0.1 |                                           |
| root  | ::1       |                                           |
|       | localhost |                                           |
| root  | %         | *3D56A309CD04FA2EEF181462E59011F075C89548 |
| admin | 127.0.0.1 |                                           |
+-------+-----------+-------------------------------------------+
6 rows in set (0.11 sec)

mysql> SELECT password('xxx');
+-------------------------------------------+
| password('xxx')                           |
+-------------------------------------------+
| *3D56A309CD04FA2EEF181462E59011F075C89548 |
+-------------------------------------------+
1 row in set (0.11 sec)

mysql>

A quick way to check the state of the passwords is to connect over IP and issue the following query:

Note that setting the root passwords only applies the connections coming over IP. The connections from App Engines show to the MySQL server as coming from localhost. So make sure the password for 'root@localhost' is the one you configured in the code.

The above shows how an instance shows up after setting the root password for connections over IP ('root@%') to 'xxx'. Note that the password for 'root@localhost' is blank so connections from App Engine still do not require any passwords.

Note
Rectangle 27 0

php App engine fails to connect to Google cloud sql?


When connecting to Cloud SQL from an authorized App Engine application, the password is not required (actually it will fail if you try to connect with password).

Note
Rectangle 27 0

php App engine fails to connect to Google cloud sql?


mysql> SELECT user,host,password FROM mysql.user;
+-------+-----------+-------------------------------------------+
| user  | host      | password                                  |
+-------+-----------+-------------------------------------------+
| root  | localhost |                                           |
| root  | 127.0.0.1 |                                           |
| root  | ::1       |                                           |
|       | localhost |                                           |
| root  | %         | *3D56A309CD04FA2EEF181462E59011F075C89548 |
| admin | 127.0.0.1 |                                           |
+-------+-----------+-------------------------------------------+
6 rows in set (0.11 sec)

mysql> SELECT password('xxx');
+-------------------------------------------+
| password('xxx')                           |
+-------------------------------------------+
| *3D56A309CD04FA2EEF181462E59011F075C89548 |
+-------------------------------------------+
1 row in set (0.11 sec)

mysql>

A quick way to check the state of the passwords is to connect over IP and issue the following query:

Note that setting the root passwords only applies the connections coming over IP. The connections from App Engines show to the MySQL server as coming from localhost. So make sure the password for 'root@localhost' is the one you configured in the code.

The above shows how an instance shows up after setting the root password for connections over IP ('root@%') to 'xxx'. Note that the password for 'root@localhost' is blank so connections from App Engine still do not require any passwords.

Note
Rectangle 27 0

php App engine fails to connect to Google cloud sql?


mysql> SELECT user,host,password FROM mysql.user;
+-------+-----------+-------------------------------------------+
| user  | host      | password                                  |
+-------+-----------+-------------------------------------------+
| root  | localhost |                                           |
| root  | 127.0.0.1 |                                           |
| root  | ::1       |                                           |
|       | localhost |                                           |
| root  | %         | *3D56A309CD04FA2EEF181462E59011F075C89548 |
| admin | 127.0.0.1 |                                           |
+-------+-----------+-------------------------------------------+
6 rows in set (0.11 sec)

mysql> SELECT password('xxx');
+-------------------------------------------+
| password('xxx')                           |
+-------------------------------------------+
| *3D56A309CD04FA2EEF181462E59011F075C89548 |
+-------------------------------------------+
1 row in set (0.11 sec)

mysql>

A quick way to check the state of the passwords is to connect over IP and issue the following query:

Note that setting the root passwords only applies the connections coming over IP. The connections from App Engines show to the MySQL server as coming from localhost. So make sure the password for 'root@localhost' is the one you configured in the code.

The above shows how an instance shows up after setting the root password for connections over IP ('root@%') to 'xxx'. Note that the password for 'root@localhost' is blank so connections from App Engine still do not require any passwords.

Note
Rectangle 27 0

php App engine fails to connect to Google cloud sql?


When connecting to Cloud SQL from an authorized App Engine application, the password is not required (actually it will fail if you try to connect with password).

Note
Rectangle 27 0

php App engine fails to connect to Google cloud sql?


couldn't connect to "{connectionName}": dial tcp {ip address}:3307: getsockopt: operation timed out

I then tried connecting via a different internet connection and was able to connect. Turns out it was the firewall in the original connection that was not letting the connection happen! Double check any security settings in place that may prevent the connection from going through.

One thing I tried was trying to connect to my application via a MySQL client directly to my proxy to see if my code was the problem: See: Connecting mysql Client Using the Cloud SQL Proxy

That still didn't work for me, which lead me to believe it may be something with the actual network connection. I noticed the Cloud SQL proxy I was running locally did return the right instance IP address (the error looked something like this:

You can confirm the IP Address returned there matches with the one in the Cloud SQL Console.

Note
Rectangle 27 0

php App engine fails to connect to Google cloud sql?


couldn't connect to "{connectionName}": dial tcp {ip address}:3307: getsockopt: operation timed out

I then tried connecting via a different internet connection and was able to connect. Turns out it was the firewall in the original connection that was not letting the connection happen! Double check any security settings in place that may prevent the connection from going through.

One thing I tried was trying to connect to my application via a MySQL client directly to my proxy to see if my code was the problem: See: Connecting mysql Client Using the Cloud SQL Proxy

That still didn't work for me, which lead me to believe it may be something with the actual network connection. I noticed the Cloud SQL proxy I was running locally did return the right instance IP address (the error looked something like this:

You can confirm the IP Address returned there matches with the one in the Cloud SQL Console.

Note