title: mysql.sock not found, where can i find it?
body: <p>On a CentOS 7 machine, I am getting the following error when I try to log into mysql from the terminal:  </p>
  
  <pre><code>ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
  </code></pre>
  
  <p>I then tried <code>cd /var/lib/mysql</code> and <code>ls -al</code>, but the resulting list of files did not contain <code>mysql.sock</code>.  <strong>So where can I find <code>mysql.sock</code> and how can I resolve this error?</strong>  </p>
  
  <p>Here are a number of things I have tried already:  </p>
  
  <p>1.) When I saw that <code>systemctl status mysqld</code> showed that mysql was stopped, I also tried <code>systemctl start mysqld</code> but the terminal just gave an unresponsive cursor without a new prompt, as if it were held up waiting for something, but it remained in that limbo state indefinitely.  </p>
  
  <p>2.) So I opened another terminal window and ran <code>systemctl status mysqld</code>, only to see that mysqld was again started.  But the error persists.  </p>
  
  <p>3.) I tried <code>find / -name "mysql.sock"</code> but the response was <code>find: ‘/run/username/1000/gvfs’: Permission denied</code>.  </p>
  
  <p>4.) Then I read <a href="https://stackoverflow.com/questions/5530215/mysql-problem-no-mysql-sock">this posting</a> and tried <code>mysqladmin | grep d.sock</code> but there were no results.  </p>
  
  <p>5.) I even resorted to <code>yum remove mysql</code> followed by <code>yum install mysql</code>, but then <code>mysql -u root</code> still gives the same original error at top of this posting.  </p>
  
  <p>6.) And then I read <a href="https://stackoverflow.com/questions/748478/cannot-find-mysql-sock">this other posting</a>, but <code>mysqladmin variables</code> gives the same error that it cannot connect because the <code>mysql.sock</code> cannot be found.   </p>
  
  <p>7.) And I tried <code>ln -s /tmp/mysql.sock /var/mysql/mysql.sock</code> but the same error persisted even though a link to mysql became visible when I tried <code>cd /var/lib/mysql/</code> and <code>ls -al</code></p>
  
  <p>8.) Since the problem may have to do with the fact that <code>systemctl start mysqld</code> gets hung up, I read <a href="https://stackoverflow.com/questions/20310782/mysql-daemon-failed-to-start-centos-6">this posting</a> and tried <code>chown -R mysql:mysql /var/lib/mysql</code> and <code>systemctl start mysqld</code> but the result is <code>Failed to issue method call: Unit mysqld.service failed to load: No such file or directory.</code>  </p>
  
  <p>9.) I then read <a href="https://dba.stackexchange.com/questions/48777/mysql-sock-missing">this posting</a>, which caused me to run <code>mysql --help | grep "Default options" -A 1</code>. The result printed the locations where <code>mysql</code> looks for <code>my.cnf</code>.  I thus checked every location, and there was no <code>my.cnf</code> file to be found. But I did find a <code>mysql.cnf.rpmsave</code>, so I tried <code>mv mysql.cnf mysql.cnf.rmpsave</code>.  This caused there to be a <code>my.cnf</code> in the expected directory, but <code>systemctl status mysqld</code> says that <code>mysqld</code> is not found.  I tried <code>yum install mysql</code> again, but it told me that <code>mysql</code> is already installed.  <strong>So I suspect that the newly renamed <code>my.cnf</code> is corrupted.  If so, how can I fix it?</strong>  <a href="https://jumpshare.com/v/xImomZMASgLWPUZ4Ic70?b=rr8My67FzHTNqagmLbTg" rel="nofollow noreferrer">Here is the link</a> to a copy of the newly renamed <code>my.cnf</code> on a file sharing site.</p>