469,621 Members | 1,678 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,621 developers. It's quick & easy.

Can not connect mysql from php

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?

Nov 23 '05 #1
2 2556
>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?


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
argument.

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

Gordon L. Burditt
Nov 23 '05 #2
Hi Gordon,

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

Nov 25 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

20 posts views Thread by Mr Dygi | last post: by
reply views Thread by Bill Hernandez | last post: by
reply views Thread by Ryan Stewart | last post: by
reply views Thread by xiuchuanli | last post: by
2 posts views Thread by Martin | last post: by
5 posts views Thread by scorpionbilli | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.