By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,070 Members | 1,718 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,070 IT Pros & Developers. It's quick & easy.

Can not connect mysql from php

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
>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

P: n/a
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.