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

前端 未结 30 1606
南方客
南方客 2020-11-22 11:30

I am getting the following error when I try to connect to mysql:

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

30条回答
  •  轮回少年
    2020-11-22 11:39

    This is a problem if you are running out of disk space. Solution is to free some space from the HDD.

    Please read more to have the explanation :

    If you are running MySQL at LINUX check the free space of HDD with the command disk free :

     df 
    

    if you are getting something like that :

    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/sda2              5162828   4902260         0 100% /
    udev                    156676        84    156592   1% /dev
    /dev/sda3              3107124     70844   2878444   3% /home
    

    Then this is the problem and now you have the solution!

    Since mysql.sock wants to be created at the mysql folder which is almost always under the root folder could not achieve it because lack of space.

    If you are periodicaly give the ls command under the mysql directory (at openSUSE 11.1 is at /var/lib/mysql) you will get something like :

    hostname:/var/lib/mysql #
    .protected  IT     files        ibdata1             mysqld.log  systemtemp
    .tmp        NEWS   greekDB      mysql               mysqld.pid  test
    ARXEIO      TEMP1  ib_logfile0  mysql.sock          polis
    DATING      deisi  ib_logfile1  mysql_upgrade_info  restore
    

    The mysql.sock file appearing and disappearing often (you must to try allot with the ls to hit a instance with the mysql.sock file on folder).

    This caused by not enough disk space.

    I hope that i will help some people!!!! Thanks!

提交回复
热议问题