Hi Dieter,

I added the port in code, the issue still there. BTW, this script works
fine when I run it manually in Linux server.

And it is strange that when I change "10.224.71.99" into "localhost".
The issue is gone when I use the PHP page. 

Thanks,
Watson

-----Original Message-----
From: Dieter Maurer [mailto:die...@handshake.de] 
Sent: Wednesday, January 19, 2011 2:48 PM
To: Watson Xu
Cc: db-sig@python.org
Subject: Re: [DB-SIG] Cannot connect to Mysql DB when I try to start a
Pyhonscript from PHP page.

Watson Xu wrote at 2011-1-18 10:20 +0800:
>I created a PHP page and one Python script. Please see the following in
>blue for the PHP source code and the Python script. When I launch the
>PHP page in IE to start the python script, the python script give me
the
>error information shown as blow, please see the following error
>information in yellow. Could you give me some suggestions for it?
Thanks
>a lot!
> ...
>Python Script (/var/www/html/test.py):
>--------------------
> ...
>import MySQLdb
>
>MySQLdbHost="yyy.yyy.yyy.yyy"
>MySQLdbUser="yyy"
>MySQLdbPassword="yyy"
>MydbSID="yyy"
>MydbPort=3306
> ...
>Myconn=MySQLdb.connect(host=MySQLdbHost, user=MySQLdbUser,
>passwd=MySQLdbPassword, db=MydbSID, port=MydbPort)
> ...
>    super(Connection, self).__init__(*args, **kwargs2)
>
>_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL
>server on '10.224.71.99' (13)")

Your problem is neither on the PHP nor the Python side.

Instead, it lies with the MySQL connection parameters.
Apparently, there is no MySQL at port "3306" at host "10.224.71.99"
or it refuses to speak with this client.



--
Dieter
_______________________________________________
DB-SIG maillist  -  DB-SIG@python.org
http://mail.python.org/mailman/listinfo/db-sig

Reply via email to