MySQL Forums
Forum List  »  PHP

mysql_connect() socket issue
Posted by: James King
Date: January 08, 2007 12:04PM

Hello fellow devs!

I'm encountering the following error:

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (13) in /path/to/my/script.php on line 44

the connection parameters look like:

mysql_connnect(localhost, $user, $password)

I'm running the latest Debian with the mysql 5, apache2, and php5 packages.

What I've done so far:

When we first got the error, couldn't connect via php, the mysql CLI, or anything else. Thought a mysqld thread must've kernel-dumped. Killed the mysqld processes and ran /etc/init.d/mysql start. Checked that /tmp/mysql.sock exists and has proper permissions. Everything fine. Could connect fine with the CLI, tested port with telnet... everything cool.

Everything could connect except PHP which was still throwing the same error. Restarted apache2 as well as mysql again -- no change, everything except PHP can connect.

got mysql_connect() to work if I used the domain of the machine in place of the localhost keyword. Obviously the localhost keyword isn't resolving in PHP or something, but I can't figure out why or how.

Thoughts?



Edited 1 time(s). Last edit at 01/08/2007 12:27PM by James King.

Options: ReplyQuote


Subject
Written By
Posted
mysql_connect() socket issue
January 08, 2007 12:04PM
January 08, 2007 12:36PM
January 08, 2007 01:14PM
January 10, 2007 01:17PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.