PHP won't connect to MySQL
Posted: Fri Oct 22, 2004 4:17 pm
I'm running PHP5 on Fedora Core2 with a fresh install of MySQL 4.1 max.
I womped my old mysql which was installed via an rpm, this time I installed from the binaries. When I first tried to connect with MySQL -CC it had the socket path as /var/lib/mysql/, this was the old path. When I changed it to /tmp/mysql.sock, then I could connect. I can connect from my Fedora box and I can connect from my windows box, with the control center and via a shell, but I can't do it through PHP. It is still looking for it in /var/lib/mysql/.
Here's the error:
I created an /etc/my.cnf file and put the socket path in there, when I did that I could not connect from anywhere. I deleted that line and all the connections came back, except PHP of course.
I'm stumped
Thanks,
- dstefani
I womped my old mysql which was installed via an rpm, this time I installed from the binaries. When I first tried to connect with MySQL -CC it had the socket path as /var/lib/mysql/, this was the old path. When I changed it to /tmp/mysql.sock, then I could connect. I can connect from my Fedora box and I can connect from my windows box, with the control center and via a shell, but I can't do it through PHP. It is still looking for it in /var/lib/mysql/.
Here's the error:
I tried editing my php.ini on the mysql.default_socket = /tmp/mysql.sock line but with no success.Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /usr/local/apache2/htdocs/clca/www/includes/incConnect.php on line 13
Could not connect : Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
I created an /etc/my.cnf file and put the socket path in there, when I did that I could not connect from anywhere. I deleted that line and all the connections came back, except PHP of course.
I'm stumped
Thanks,
- dstefani