mysql_connect() doesn't work when run by apache; works from command line.
Posted
by Skeeter
on Stack Overflow
See other posts from Stack Overflow
or by Skeeter
Published on 2010-06-11T05:34:34Z
Indexed on
2010/06/11
5:42 UTC
Read the original article
Hit count: 154
Hi, I have a strange issue. I'm trying to write a simple php webpage on my server, but mysql_connect() doesn't connect to any server, either local or otherwise. Here's where it gets strange. If I take the same php script and run it from the commandline, the script works. phpinfo() indicates that both the file (being run by apache) and the commandline (run as root) are calling the same version of php, mysql is loaded, and the php.ini is the same.
Furthermore, I'm running a MediaWiki installation on this same server, and it's using the mysqld installed locally and works just fine, so I'm completely at a loss as to why the code isn't working. The error I receive on runtime:
Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (13)
(The IP is x'd out for the privacy of the owner of the server I'm connecting to)
© Stack Overflow or respective owner