[MySQL] How to create a .sock file?

Glaanieboy

OSNN Veteran Addict
Joined
6 Mar 2002
Messages
2,628
I got an Apache2/php4/MySQL4.0 installation running on my Slackware Linux box. All is installed fine, but I got one little issue. PHP refuses to connect to MySQL, this error occurs:
Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)
I peeked into /var/run/mysql/ and the file isn't there, only mysql.pid.
I have checked the rights for that dir, they are 755 for user mysql and group mysql, so it should be able to wrote to that dir upon startup. How can I fix this problem?
 
Check /tmp for a mysql.sock

Then check your php.ini and point it at the right location.

It should also contain an option to disable sock operations, and instead just connect on a certain port, for this, also check PHP.ini.

You could always if it is in /tmp:

cd /var/run/mysql/
ln -s /tmp/mysql.sock

And be done with it. Butthat is up to you.

X-Istence
 
This can be caused if you do not have an /etc/my.cnf file
 
j79zlr said:
This can be caused if you do not have an /etc/my.cnf file

it would fall back to the standard location, which is either /tmp or /var/tmp

X-Istence
 
try it ;)

<<edit>>

Hmmm mysql restarted without the my.cnf file, I would swear it wouldn't, I know it wouldn't used to.
 
I did have a my.cnf file in my /etc dir, so that wasn't the case. I set the mysql.default.socket option to /tmp/mysql.sock and all was good again. I was used to FreeBSD porting system, where all the options are set correctly, guess compiling from source takes a bit more configuring. Anyway, another thing learnt, it's getting more fun!
 
j79zlr said:
try it ;)

<<edit>>

Hmmm mysql restarted without the my.cnf file, I would swear it wouldn't, I know it wouldn't used to.

You swear it would not? It does on my 3.x install which is running on BSD. Same thing with the new 4.1 and the bit older 4.0.

See i knew this for one reason only, because the FreeBSD ports tree does not add a standard my.cnf anywhere, so there is nothing to read from. This means it has to somehow do it from some standard it has either compiled in at compile time, or because it was hard coded in the code.
 
Yea, but I remember sepcifically having that promlem where it couldn't create the socket file until I copied one of the my.cnf default files into /usr/local/etc/. This was with MySQL 3.x years ago.

MySQL installs example my.cnf's into /usr/local/share/mysql/
 
Hrm, never had that problem. If permissions were wrong on /var/tmp to create a mysql.sock it would fall back to /tmp which almost always will allow a socket to be created.
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back