Page 1 of 1

PHP won't connect to MySQL

Posted: Fri Oct 22, 2004 4:17 pm
by dstefani
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:
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 tried editing my php.ini on the mysql.default_socket = /tmp/mysql.sock line but with no success.

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

Posted: Fri Oct 22, 2004 5:17 pm
by sakaveli
hi,

im no expert but i had the very same error last week and tried everything to solve it, but the problem in the end was ver simple to solve, it was a mis-spelling of one the lines that connect to the DB.

just re-check to make sure you have not done what i did!

sak