Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing /var/lib/mysql/mysql.sock file

Tags:

I'm trying to access mysql and when I run the mysql command, I get the following.

[root@ip-10-229-65-166 tpdatabase-1.8.0.28356]# mysql

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

Doing this returns nothing

[root@ip-10-229-65-166 mysqld]# find -name mysql*

[root@ip-10-229-65-166 mysqld]# /etc/init.d/mysql stop -bash: /etc/init.d/mysql: No such file or directory

[root@ip-10-229-65-173 tpdatabase-1.8.0.28356]# mysql_config |grep -- --socket

--socket [/var/lib/mysql/mysql.sock]

Maybe a permissions problem?

I do have mysql installed using yum install mysql

I'm running CentOS 5.4 on a Amazon EC2 Cloud Instance

like image 835
unleashed Avatar asked Apr 14 '11 09:04

unleashed


People also ask

Why mysql sock is missing?

sock is created by the mysql daemon on start, and it is removed (or, becomes un-connectable) if this daemon stops. This message is given by some client process, trying to connect your mysqld on this socket without success. Its most likely reason is that the mysqld doesn't run.

Where is the mysql sock file?

The default location for the Unix socket file that the server uses for communication with local clients is /tmp/mysql. sock . (For some distribution formats, the directory might be different, such as /var/lib/mysql for RPMs.)

What is var lib mysql mysql sock?

If you run into this error message while trying to connect to a local MySQL Server: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' It means either the MySQL server is not installed/running, or the file mysql.


2 Answers

You need to install the server package:

sudo yum install mysql-server 

After installation, you have to start the service:

sudo service mysqld start 
like image 71
Alicia Casuso Avatar answered Oct 29 '22 19:10

Alicia Casuso


rm -rvf /var/lib/mysql/ib_logfile* touch /var/lib/mysql/mysql.sock touch /var/lib/mysql/mysql.pid chown -R mysql:mysql /var/lib/mysql systemctl restart mysql 

try this and check the permission of both /var/lib/mysql/mysql.sock and /tmp

like image 22
Indharajith Ravichandran Avatar answered Oct 29 '22 19:10

Indharajith Ravichandran