When tried to connect to mysql database through python MySQLdb getting following err:
File "/var/www/cgi-bin/add_user.py", line 39, in <module>
addEntry(prop.text.strip())
File "/var/www/cgi-bin/add_user.py", line 19, in addEntry
db = mdb.connect(host="203.171.xx.xx", user="usrone", passwd="psdone", db="test", port=3306)
File "/usr/lib64/python2.6/site-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/usr/lib64/python2.6/site-packages/MySQLdb/connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (2003, "Can't connect to MySQL server on '203.171.xx.xx' (13)")
python code used to connect is as below:
import MySQLdb as mdb
db = mdb.connect(host="203.171.xx.xx", user="usrone", passwd="psdone", db="test", port=3306)
this code is working when used from python command prompt however it fails with above error when used from cgi script.
I have checked the wireshark captures and noticed that command failed without even connecting to remote mysql server.
Apache server version : Apache/2.2.15 I have given all permissions (chmod 777) to python script file.
Any suggestion as to why this might happen?