Can not connect mysql from php

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I install Fedora 4 with web server, after that I installed mysql
5.0.15. Now I can connect to mysql from command line and
mysql-administrator and mysql-query-browser. But when I try to test to
connect from php code, it told me that "can not connect to local mysql
through /tmp/mysql.sock. /tmp/mysql.sock is my sock file to connect and
permission is set good. when I add phpinfo() to my php code, it show me
that mysql lib php uses is 4.1.X, and sockect file is
/var/lib/mysql.sock. It looks like PHP mysql module still be old
version, and can not connect to the new 5.0.15. Anybody can give a hint
on that?

Re: Can not connect mysql from php

Quoted text here. Click to load it

You need PHP and the MySQL server to agree on where the socket is.

One way is to set mysql.default_socket and/or mysqli.default_socket
in php.ini.  Another way is to pass the correct parameters, including
the socket path, to mysqli->connect or mysql_connect().  For
mysql_connect(), you pass servername:/path/to/socket for the server

Be sure to restart the web server after changing php.ini.

                        Gordon L. Burditt

Re: Can not connect mysql from php

Hi Gordon,

Thank you for your reply, but I tried both of your advices. no, not

Site Timeline