App引擎无法连接到Google云端SQL [英] App engine fails to connect to Google cloud sql

查看:123
本文介绍了App引擎无法连接到Google云端SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 'PDOException'带有消息' SQLSTATE [HY000] [2002]由于目标机器主动拒绝它,因此无法建立连接。 

我仔细检查了文档并遵守了相关说明。我将该应用程序添加为授权应用程序,并使用云控制台设置root密码。我也给了instace一个ip地址,并且可以从本地开发机器上的Workbench连接到它。使用工作台,我添加了一个用户和配置的权限。但是我仍然无法从应用程序的开发版本(与工作台相同的ip)或部署的应用程序连接到它。



以下是我的连接线:

  $ conn = new PDO('mysql:unix_socket = / cloudsql / ****:****; charset = utf8' ,'the_username','its_password'); 

question 似乎与此问题类似。但是,即使设置新用户并授予权限,我仍然无法连接。任何想法,哪里出错了?



谢谢

解决方案

设置根密码仅适用于通过IP进行的连接。来自App Engines的连接向本地主机显示的MySQL服务器显示。因此,请确保'root @ localhost'的密码是您在代码中配置的密码。



检查密码状态的快速方法是通过IP连接并发出以下查询:

  mysql> SELECT用户,主机,密码FROM mysql.user; 
+ ------- + ----------- + ------------------------- ------------------ +
|用户|主机|密码|
+ ------- + ----------- + ------------------------- ------------------ +
| root | localhost | |
| root | 127.0.0.1 | |
| root | :: 1 | |
| | localhost | |
| root | %| * 3D56A309CD04FA2EEF181462E59011F075C89548 |
| admin | 127.0.0.1 | |
+ ------- + ----------- + ------------------------- ------------------ +
6行设置(0.11秒)

mysql> SELECT password('xxx');
+ ------------------------------------------- +
|密码('xxx')|
+ ------------------------------------------- +
| * 3D56A309CD04FA2EEF181462E59011F075C89548 |
+ ------------------------------------------- +
1行设置(0.11秒)

mysql>

以上显示了在为IP上的连接设置root密码后(root @ %')到'xxx'。请注意,'root @ localhost'的密码为空,所以来自App Engine的连接仍然不需要任何密码。


My Google app engine application fails to connect to Google cloud sql instance with this error:

'PDOException' with message 'SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it.

I've checked the documentation and followed instructions closely. I added the app as an authorised application and set the root password using the cloud console. I also gave the instace an ip address and can connect to it from Workbench on the local development machine. Using workbench, I added a user and configured permissions. But I'm still unable to connect to it from the dev version of the app (same ip as workbench) or the deployed app.

Here's my connection line:

$conn = new PDO('mysql:unix_socket=/cloudsql/****:****;charset=utf8', 'the_username', 'its_password');

this question appears to be similar to this problem. However, even after setting up a new user and granting permissions I'm still unable to connect. Any idea where I went wrong?

Thanks

解决方案

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.

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

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>

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.

这篇关于App引擎无法连接到Google云端SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆