Help with understanding mysql socket


I’ve been asked to take over hosting of a client’s existing website and I’m struggling to get it up and running on my test version, as it is using a very different approach to PHP to how I would normally do things. Any help with understanding some of the issues would be much appreciated.

The config file for the database specifies a MySQL socket :/var/lib/mysql/mysql.sock and when I load the site, I get an unknown MySQL server host error. I’m not sure whether the issue is with the path specified or whether I need to do something so that this socket file is created automatically.

I’ve read a few threads relating to MySQL sockets but the suggestions are all command line based, which is not permitted on my shared server.

If anyone can help me get my head round what sockets are, and how I might find a solution on this, I’d be very grateful.

Many thanks in advance.

PHP uses the mySQL socket connection when the server is set to ‘localhost’

Hope this helps you.

A socket file doesnt actually contain data, it transports it… It is a special, unusual type of file created with special system calls/commands. It is not an ordinary file.

It is like a pipe the server and the clients can use to connect and exchange requests and data. Also, it is only used locally. Its significance is merely as an agreed rendezvous location in the filesystem.

Creating a plain old file and putting it in that location may actually interfere with the server creating it… and thereby prevent local clients from connecting to the server.

Thanks for taking the time to reply. I think I’ve got my head round this and have the socket part of the problem fixed now.