Configuring MySQL connection in Google App Engine PHP SDK on Windows 7

故事扮演 提交于 2020-01-06 08:27:15

问题


Need basic help configuring Google App Engine SDK on a Windows 7 system to use a local install of MySQL. The GAE install is vanilla (GAE 1.8.8, Python 2.7.6, PHP 5.4), with MySQL 5.6.15 also installed. I am able to use the MySQL console, so MySQL is running. PHP is also running.

When I run a short PHP script consisting almost entirely of this line:

$dbconn = mysql_connect('localhost','root','rootpwd');

this is the error message I get:

Warning: mysql_connect(): No connection could be made because the target machine actively refused it.

My question: What settings do I need to add or change to allow my PHP scripts to connect to MySQL?

My root username and password are correct, as verified by my ability to access MySQL through the console. There are some difference between the GAE SDK setup and that of a WAMP server, which I also have installed on the same machine but which is not running now. Is there still likely to be a conflict between the freshly installed MySQL instance and the one on the WAMP server? Are there some environment variables (in Windows, in the SDK, or elsewhere) that I need to set?

I'm fairly sure this question has been asked before, but the answers I am seeing are either more complex than I can believe would be necessary, or simply gloss over the details of configuring the connection. Any help would be appreciated.


FIGURED IT OUT... Apparently my script was being pointed to the MySQL instance from the WAMP server, which was not running when I tried to connect in the script. As soon as I started that MySQL instance, the script connected to it.

So the moral of the story is... if you already have a MySQL instance installed outside of the GAE SDK, as long as that service is running your GAE PHP script will find it, and there's no need to install another MySQL instance just for the Google SDK.


回答1:


You must allow external connection.

I don't know the path, but, apparently, the GAE connects to localhost not directly.

You can change the "localhost" by "127.0.0.1" to test it, or to "::1".

Some links to try change MySql external connections rules.

http://www.thegeekstuff.com/2010/08/allow-mysql-client-connection/

How to allow remote connection to mysql



来源:https://stackoverflow.com/questions/20600886/configuring-mysql-connection-in-google-app-engine-php-sdk-on-windows-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!