Page 1 of 1

mysql server connection error

Posted: Sun May 11, 2003 8:56 pm
by dickey
Using script under unix:
mysql_connect("localhost", "user", "user_password")or die("server connection error");
mysql_select_db("bt") or die("database connection error");

Returns error message:
Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)
Server connection error

PHP seems to be functioning well.

Checked php.ini, nothing stands out as an issue.

Code: Select all

mysql.allow_persistent = On
mysql.max_persistent	 = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_host =
mysql.default_user =
mysql.default_password =

Any assistance will be appreciated.

-Andrew

Posted: Sun May 11, 2003 9:10 pm
by volka
http://php.net/mysql_connect
Note: Whenever you specify "localhost" or "localhost:port" as server, the MySQL client library will override this and try to connect to a local socket (named pipe on Windows). If you want to use TCP/IP, use "127.0.0.1" instead of "localhost". If the MySQL client library tries to connect to the wrong local socket, you should set the correct path as mysql.default_host in your PHP configuration and leave the server field blank.
The socket-path configuration stands in my.cnf (at least it should ;) )

Thanks Volka

Posted: Sun May 11, 2003 9:24 pm
by dickey
Changing the script to 127.0.0.1:3306 etc works.

I haven't ever needed to specify it in that way before.

Thanks again.