Hi,
I have an apache server (version Apache/2.2.15) configured to use python script. The script is supposed to connect to database and inserts data to table.
I have written a simple code as below:
import MySQLdb as mdb
db = mdb.connect(host="mysql", user="one", passwd="two", db="test")
cur = db.cursor()
querystring = "INSERT INTO mytable (username, password) value (\"%s\", \"%s\")"%("aaa","bbb")
This code works fine when used from python command terminal, but fails when used from cgi script.
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)")
The script file has all permissions (chmod 777) and firewall is disabled in both the pc's
any suggestions as to why this might happen?
Thanks