Error connecting to MySQL No '/tmp/mysql.sock'

jmd

Verified User
Joined
Jun 5, 2013
Messages
9
Hi,

I rebooted my server and now I'm having a problem with mysql. In DirectAdmin I'm getting the following error (in DA/User/MySQL Databases):
Error connecting to MySQL: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
If I go to phpMyAdmin I get the same error after logging in:
#2002 - Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
The server is not responding (or the local server's socket is not correctly configured).



I've had a look at the /tmp folder and there is no mysql.sock file there.


I've SSH'd as root and looked into the problem and I have noticed that the folder /etc/mysql doesn't exist. I see a folder called mysql.moved which contains the my.cnf file. I copied it to /etc/mysql as I think it should be in that location.

I ran the command find -name mysql.sock and have no results.


Code:
root@server:/# /etc/init.d/mysqld stop
Stopping mysqld:                [ FAILED ]
root@server:/# /etc/init.d/mysqld start
Starting mysqld:                [ OK ]
root@server:/#



root@server:/var/lib/mysql# ps aux | grep mysql
Code:
root      1560  0.0  0.0   9140  1396 ?        S    Jun15   0:00 /bin/sh /usr/bin/mysqld_safe
mysql     1691  0.0  0.1 168728 22608 ?        Sl   Jun15   0:14 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid [B]--socket=/var/run/mysqld/mysqld.sock --port=3306[/B]
root      1692  0.0  0.0   3856   628 ?        S    Jun15   0:00 logger -t mysqld -p daemon.error
root      3207  0.0  0.0   7548   860 pts/0    S+   04:23   0:00 grep mysql

I looked in /var/run/mysqld but mysqld.sock doesn't exist in that location there is only the mysqld.pid file in there).

I have read this:
http://www.tech-recipes.com/rx/762/...cal-mysql-server-through-socket-tmpmysqlsock/
But I'm not sire it helped as there is no mysqld.sock file I can see.

I've read a few other posts on the matter but haven't found a solution to this problem. This was the first reboot to this machine. My biggest concern is why/how this happened?
 
I would guess that you have installed/upgraded mysql in yum? If so, you should not have done that, it should only be installed by custombuild. When you setup a server, it should be a minimal install without mysql, php, apache etc, because all those are installed/upgraded by custombuild/directadmin. Try:

Code:
cd /usr/local/directadmin/custombuild
./build update
./build mysql
./build php n
 
I did not install MySQL, I'm sure it was installed with DA.
I have many databases on this box, just want to make sure that I'm not going to overwrite them?
Also, how to get MySQL to start next time u reboot this machine?
 
my.cnf should just be in /etc/my.cnf

You can set the socket file with this config.
 
ditto:
HTML:
cd /usr/local/directadmin/custombuild
./build update
./build mysql
./build php n

I followed this, the socket file has been created when sql starts as normal.

Is this going to happen again when I restart the server?

scsi:
yes my.cnf is in that location. Thanks.
 
Back
Top