MySQL Sock Error - Existing threads no help

dempsey

Active Member
Jul 17, 2003
26
0
151
I know there are already loads of threads about MySQL.Sock errors, but I have read through all of the ones I could find and none of them helped me.

I have just restored my server from the old HD and everything seems to be working now apart from MySQL, giving me the error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

I can't seem to find a myqsl.sock file anywhere, I looked in /tmp, /var/tmp, /var/lib/mysql.

I have tried /scripts/fixmysql and that doesn't help, nor does /scripts/mysqlup --force

Is there anyway to recreate a mysql.sock file? Is it just a text file with some data in?

Anyone have any ideas on something to try?

Thanks for any replies :)
 

chirpy

Well-Known Member
Verifed Vendor
Jun 15, 2002
13,437
33
473
Go on, have a guess
A few things to try:

1. Make sure /var and /tmp aren't full!

2. Ensure the file ownerships are correct:

chown -R mysql:mysql /var/lib/mysql

3. Check that /tmp is chmod 1777:

chmod 1777 /tmp

4. Pre-create the symlink in /tmp:

ln -sv /var/lib/mysql/mysq.sock /tmp/mysql.sock

5. Lastly, check /etc/my.cnf and edit it so that it only has these lines in it:
Code:
[mysqld]
set-variable = max_connections=500
safe-show-database
That pretty much covers all the cases I've found for the problem. If it still doesn't work:

/scripts/mysqlup --force
 

dempsey

Active Member
Jul 17, 2003
26
0
151
Thanks, I've tried all of those and still doesn't work. :(

/tmp wasn't full, but I emptied out a few files. What/where can I clear out in /var ?

Is there a way I can force mysql.sock to be created? Or manually make one? Or copy one from another machine? It doesn't seem to be making it. :confused:

Any other ideas?
 

AndyReed

Well-Known Member
PartnerNOC
May 29, 2004
2,217
4
193
Minneapolis, MN
dempsey said:
Thanks, I've tried all of those and still doesn't work. :(

/tmp wasn't full, but I emptied out a few files. What/where can I clear out in /var ?

Is there a way I can force mysql.sock to be created? Or manually make one? Or copy one from another machine? It doesn't seem to be making it. :confused:
That's very odd. Are you sure MySQL is installed, or installed properly, on the new server?
 

dempsey

Active Member
Jul 17, 2003
26
0
151
AndyReed said:
That's very odd. Are you sure MySQL is installed, or installed properly, on the new server?
its the same server, just a new HD, I think it's installed properly, I've tried forcing an update, but how can I try reinstalling it completly?
 

AndyReed

Well-Known Member
PartnerNOC
May 29, 2004
2,217
4
193
Minneapolis, MN
dempsey said:
its the same server, just a new HD, I think it's installed properly, I've tried forcing an update, but how can I try reinstalling it completly?
Still, make sure MySQL is installed properly.

Login to WHM and change the root password for MySQL. Then run these commands:
chmod 1777 /tmp
ps aux |grep mysql
killall -9 mysql
ln -s /var/lib/mysql/mysql.sock /var/tmp/mysql.sock
chown -R mysql:mysql /var/lib/mysql
/scripts/restartv mysql

Check on errors:
tail -f /var/log/mysqld.log

If that doesn't work, try this command:
/scripts/mysqlup --force

If that doesn't work, I suggest you hire a sys admin to fix this problem for you.
 
Last edited:

dempsey

Active Member
Jul 17, 2003
26
0
151
AndyReed said:
change the root password for MySQL
Code:
Mysql password change failed!!
A forced reset will now be attempted.

Waiting for mysql to restart.....Done
Changing Password..../usr/sbin/mysqld: ready for connections.
Version: '4.1.14-standard'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Edition - Standard (GPL)
Done
Reloading Mysqld...
Done
Waiting for mysql to terminate.....

Restarting MySQL ....Starting MySQL...................................[FAILED] Done

The MySQL root password has been changed.
AndyReed said:
ps aux |grep mysql
Code:
root     22376  0.0  0.1  3688  668 pts/0    S    10:12   0:00 grep mysql
AndyReed said:
killall -9 mysql
Code:
mysql: no process killed
AndyReed said:
/scripts/restartv mysql
Code:
-bash: /scripts/restartv: No such file or directory
So I used
Code:
/etc/init.d/mysql restart
and it returned
Code:
MySQL PID file could not be found!                         [[COLOR=Red]FAILED[/COLOR]]
Starting MySQL...................................          [[COLOR=Red]FAILED[/COLOR]]
AndyReed said:
Check on errors:
tail -f /var/log/mysqld.log
Code:
tail: /var/log/mysqld.log: No such file or directory
tail: no files remaining
AndyReed said:
If that doesn't work, try this command:
/scripts/mysqlup --force
Code:
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
mysql has failed, please contact the sysadmin (result was "Warning, no valid mysql.sock file found.mysql has failed").
Install Complete
AndyReed said:
If that doesn't work, I suggest you hire a sys admin to fix this problem for you.
Looks like I might have to :(

Thanks for trying to help :) I can't think of anything else to try now :(
 

madaboutlinux

Well-Known Member
Jan 24, 2005
1,051
2
168
Earth
dempsey said:
I know there are already loads of threads about MySQL.Sock errors, but I have read through all of the ones I could find and none of them helped me.

I have just restored my server from the old HD and everything seems to be working now apart from MySQL, giving me the error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

I can't seem to find a myqsl.sock file anywhere, I looked in /tmp, /var/tmp, /var/lib/mysql.

I have tried /scripts/fixmysql and that doesn't help, nor does /scripts/mysqlup --force

Is there anyway to recreate a mysql.sock file? Is it just a text file with some data in?

Anyone have any ideas on something to try?

Thanks for any replies :)
See if this helps you :- http://forums.cpanel.net/showthread.php?t=48890
 

jester.ro

Well-Known Member
PartnerNOC
Feb 6, 2004
304
0
166
Bucharest, Romania
cPanel Access Level
DataCenter Provider
hmm, i just had this happening on a newly installed server, and i thought i made a mistake while setting up and screwed it.

nothing worked. i tried setting pid and sock directly in my.cnf, i changed the name of the pid in /etc/init.d/mysql ...nada

even switched versions, from 4.0 to 4.1, and back.


finally i gave up and did a yum remove MySQL*
deleted the /var/lib/mysql dir and my.cnf and ran /scripts/mysqlup (after setting the desired mysql version in whm tweak settings). It worked.

This was a newly installed centos 4.2 server. Make sure u don;t loose valuable databases when deleting var/lib/mysql.
 

dempsey

Active Member
Jul 17, 2003
26
0
151
Well I think MySQL is up and running now, not sure what they did, but got someone to have a look for me, thank you to everyone for your replies :D
 

Tiago

Member
Aug 22, 2003
11
0
151
Hi,

Same problem here.

New clean install on CentOs 4.2. I solved the problem removing mysql and installing again with /scripts/mysqlup.