1

I tried restarting the Mysql server but its not working for me. I am sure the server is running and the permissions on the folder /var/lib/mysql/ are correct (777).

When i tried to open the file mysql.sock, its giving me an error saying the file may be corrupt.

Please help me log in to DB. Thanks in advance.

This is how My.cnf looks

datadir=/var/lib/mysq
socket=/var/lib/mysql/mysql.sock
user=mysql
#Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
skip-external-locking
Phil
  • 157,677
  • 23
  • 242
  • 245
MUFC
  • 1,943
  • 3
  • 14
  • 13

5 Answers5

3

mysqld has to be started in order of the mysql.sock to be created and access by any process. check whether it is running.

I had same issue and checked whether the mysqld was running and I found out that is wasn't, so I started mysqld. That should resolve the problem.

Ralph
  • 31
  • 2
0

I had the same problem a while ago. I updated my machine and the socket ceased to work. My solution was to change the socket to a location where it could be opened by every process.

In /etc/mysql/my.cnf (or where this file is)

    [client]
    port = 3306
    #socket = /var/run/mysqld/mysqld.sock
    socket = /tmp/mysqld.sock # This location did it for me


    [mysqld_safe]
    #socket = /var/run/mysqld/mysqld.sock
    socket = /tmp/mysqld.sock 
    ...

    [mysqld]
    ...
    #socket = /var/run/mysqld/mysqld.sock
    socket = /tmp/mysqld.sock
    ...

It seems important that all the profiles use the same socket. Also you would want to change the /etc/mysql/debian.cnf and update the socket. Hope this helps!

0

Unless the mysqld service is running the mysql.sock file is not present in the directory /var/lib/mysql; Please start the mysqld using service mysqld start as root user;

and then run mysql from shell to start the mysql database; This worked for me with same error message;

Krishna Oza
  • 1,390
  • 2
  • 25
  • 50
0

You may want to check the permissions, owner and group on files for the /var/lib/mysql directory, as well as the files within it.

I had a similar issue causes when i moved the /var/lib/mysql directory to a new machine. During the copy the permissions were changed, and the owner and group were changed to root. Changing the owner and group (chown user:group file/directory) and permissions (chmod <value> filename/s) to the MySQL admin account resolved the issue.

Brom558
  • 185
  • 1
  • 4
0

As what you have give from your my.cnf .

Please make sure that both socket points to same file.You are missing it.Please make it sure. Change it as i have changed

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
#Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/lib/mysql/mysql.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
skip-external-locking

your both sockets are pointing to different files.

Try it..

Abdul Manaf
  • 4,768
  • 3
  • 27
  • 34