Sunny wrote:
On 5/11/06, Alan Purchase
wrote: Hi All,
When I try to connect to web sites residing on my laptop (both http://localhost/website and http://localhost/~user/website) I get the following message: "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)". The socket in question exists in /var/lib/mysql, it is owned by the mysql.mysql user and has the necessary permissions (775). Also, the mysql folder and the database folders within it are owned by mysql.mysql and have the necessary permissions (775).
Also, when connecting to http://localhost/phpMyAdmin/ I got the following error message from MySQL: #2002 - The server is not responding (or the local MySQL server's socket is not correctly configured). However, after changing the server name in config.inc.php from localhost to 127.0.0.1 I can connect to phpMyAdmin successfully.
Has anyone any ideas on what I am doing wrong? I have googled myself silly to no avail and would appreciate some assistance.
Cheers, Alan.
Alan Purchase Tregenna Business Services 113 Victory Road Laingholm Auckland 1007 New Zealand ||
If you do not specify server name when connecting to mysql server, or if this is localhost, the clients default to connect trough socket. If you specify servername (different than localhost), or ip address, the connection is made over tcp/ip port 3306. Thats why you succeed with 127.0.0.1.
Now - your problem: to connect trough socket - the directory in which the socket is created, and the socket file have to read- and writable by the user, running the client. In your case this is most probably www. You can do this either by chmod 777, or by adding such a users in mysql group, as the socket file is created with 775 by default. The directory is writeable but just to make sure I added www to the mysql group. It made no difference, I still get the error.
Also, make sure that the clients "know" the directory of the socket file - i.e. for phpMyAdmin, check in php.ini. If you are using the commandline client (mysql), use the -s option to specify the socket.
Surely the client knows the location of the socket file as the error states that the client cannot connect to the socket file.
Cheers