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

8,011

Try restarting it to see if there are any error messages.

service mysqld restart
Share:
8,011

Related videos on Youtube

Nick Peranzi
Author by

Nick Peranzi

Updated on September 18, 2022

Comments

  • Nick Peranzi
    Nick Peranzi over 1 year

    This is NOT a duplicate of Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’

    The issue there was of insufficient disk space. No such problem here.

    I have a mysql setup on a Redhat Centos 5.5 system, which was working fine until I restarted it.

    The webapplication spits out:

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

    when trying to connect to it.

    I'm not able to run:

     root@server [~]# /usr/bin/mysql_secure_installation
     ...
     Enter current password for root (enter for none):
     ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
    

    Irrespective of what I enter (root password, earlier mysql password, or blank), it still says the same thing.

    Also:

    root@server [~]# cat /var/log/mysqld.log
    101021 18:37:34  mysqld ended
    

    Edit1: After doing service mysqld restart

    101022 00:43:46  mysqld started
    101022  0:43:46  InnoDB: Started; log sequence number 0 2820714
    101022  0:43:46 [Note] /usr/libexec/mysqld: ready for connections.
    Version: '5.0.77'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution
    
  • Nick Peranzi
    Nick Peranzi over 13 years
    It started up my application, but I'm not sure if it ended my problems... The log output in Edit1
  • Ignacio Vazquez-Abrams
    Ignacio Vazquez-Abrams over 13 years
    Sounds like it's not set to run at startup then. chkconfig mysqld on
  • Nick Peranzi
    Nick Peranzi over 13 years
    Precisely that! I did that, did a restart to check and voila!