Does anyone know why my /var/run/mysqld/mysqld.sock socket file would not be on my computer when I install (or reinstall) MySQL 5.1?

Right now, when I try to start up a server with mysqld, I get errors like Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when trying to connect, but creating a blank file with that name (as suggested on the ubuntu forums) was unsuccessful.

I had both mysql and postgres serving fine until I upgraded to natty a little while ago; I have spent hours walking through both databases trying to figure out what is going on. I can give up on postgres, but I cannot work without a working copy of mysql.

The weirdest part: I use Kubuntu, and my understanding is that KDE uses mysql to store user permissions, etc. I am not experiencing any weird permissions issues; can I take this to mean that (somehow?) MySQL is actually working?

Maybe these socket files live in a different place in natty? Would it be easier to just reinstall the os fresh? At this point, I am open to any suggestions that will stop wasting my time.

link|improve this question
feedback

migrated from stackoverflow.com Jun 10 '11 at 23:37

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 3 down vote accepted

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.

My recommendation is to remove any file you put in the location. The special socket file is created by the server.

link|improve this answer
Thanks for the explanation of socket files, and sorry about the poorly-worded question: my original issue was that the socket file was missing - the error mysql kept throwing was Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when trying to connect – egbutter Jun 11 '11 at 4:09
feedback

A socket is a special pseudo-file used for data transmission by reading and writing, not data storage.

The socket file is created when the service is started and removed when the service is terminated. The location of the file is defined in /etc/my.cnf like so:

[mysqld]
socket=/var/run/mysql/mysql.sock
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.