Mysql.sock not found, where can I find it?

On a CentOS 7 machine, I get the following error when trying to login to mysql from a terminal:

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

Then I tried cd /var/lib/mysql and ls -al , but as a result the list of files did not contain mysql.sock . So where can I find mysql.sock and how to resolve this error?

Here are a few things I've already tried:

1.) When I saw that systemctl status mysqld showed that mysql was stopped, I also tried systemctl start mysqld , but the terminal just gave an unresponsive cursor without a new prompt, as if it had been delayed, waiting for something, but it remained in this state uncertainties for an indefinite period.

2.) So, I opened another terminal window and ran systemctl status mysqld , only to see that mysqld was running again. But the error persists.

3.) I tried find / -name "mysql.sock" , but the answer was find: '/run/username/1000/gvfs': Permission denied .

4.) Then I read this publication and tried mysqladmin | grep d.sock mysqladmin | grep d.sock , but no results.

5.) I even resorted to yum remove mysql followed by yum install mysql , but then mysql -u root still gives the same original error at the top of this post.

6.) And then I read this other publication , but mysqladmin variables gives the same error that it cannot connect, because mysql.sock cannot be found.

7.) And I tried ln -s /tmp/mysql.sock /var/mysql/mysql.sock , but the same error persisted, although the mysql link became visible when I tried cd /var/lib/mysql/ and ls -al

8.) Since the problem may be due to the fact that systemctl start mysqld gets stuck, I read this publication and tried chown -R mysql:mysql /var/lib/mysql and systemctl start mysqld but the result is Failed to issue method call: Unit mysqld.service failed to load: No such file or directory.

9.) Then I read this publication , which made me start mysql --help | grep "Default options" -A 1 mysql --help | grep "Default options" -A 1 . The result printed the places where mysql looking for my.cnf . So I checked every location and my.cnf file was not found. But I found mysql.cnf.rpmsave , so I tried mv mysql.cnf mysql.cnf.rmpsave . This resulted in my.cnf in the expected directory, but systemctl status mysqld says that mysqld not found. I tried yum install mysql again, but I was told that mysql already installed. Therefore, I suspect that the recently renamed my.cnf corrupted. If so, how can I fix it? Here is a link to a copy of the recently renamed my.cnf into a site sharing file.

+6
source share
2 answers

Understand that this is an old post, but came across it myself now and found it very difficult to find the right solution. I solved this by doing the following:

  • Install zlib :

     32-Bit Debian/Ubuntu: apt-get install zlib1g 64-Bit Debian/Ubuntu: apt-get install lib32z1 32/64-Bit Fedora: yum install zlib.i686 32/64-Bit Mandriva: urpmi zlib1 32-Bit SUSE: zypper install libz1 64-Bit SUSE: zypper install libz1-32bit 
  • Connect to 127.0.0.1 instead of localhost if this option is available to you. When connecting MySQL through 127.0.0.1 and localhost use different methods (TCP for the former, Sock for the latter)

  • Make sure your firewall is not blocking the internal ports, it may be worthwhile to disable it temporarily to make sure that it is not.

+1
source

Here is a detailed example on how you can fix this problem. If you closely follow all these steps, you should install it in a short time.

0
source

Source: https://habr.com/ru/post/979670/


All Articles