title: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' -- Missing /var/run/mysqld/mysqld.sock
body: <p>My problem started off with me not being able to log in as root any more on my mysql install.  I was attempting to run mysql without passwords turned on... but whenever I ran the command</p>
  <pre class="lang-none prettyprint-override"><code># mysqld_safe --skip-grant-tables &amp;
  </code></pre>
  <p>I would never get the prompt back. I was trying to follow <a href="http://www.cyberciti.biz/tips/recover-mysql-root-password.html" rel="noreferrer">these instructions to recover the password</a>.</p>
  <p>The screen just looks like this:</p>
  <pre class="lang-none prettyprint-override"><code>root@jj-SFF-PC:/usr/bin# mysqld_safe --skip-grant-tables
  120816 11:40:53 mysqld_safe Logging to syslog.
  120816 11:40:53 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
  </code></pre>
  <p>and I don't get a prompt to start typing the SQL commands to reset the password.</p>
  <p>When I kill it by pressing <kbd>CTRL</kbd> + <kbd>C</kbd>, I get the following message:</p>
  <pre class="lang-none prettyprint-override"><code>error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
  
  Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
  </code></pre>
  <p>If I retry the command and leave it long enough, I do get the following series of messages:</p>
  <pre class="lang-none prettyprint-override"><code>root@jj-SFF-PC:/run/mysqld# 120816 13:15:02 mysqld_safe Logging to syslog.
  120816 13:15:02 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
  120816 13:16:42 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
  
  [1]+  Done                    mysqld_safe --skip-grant-tables
  root@jj-SFF-PC:/run/mysqld#
  </code></pre>
  <p>But then if I try to log in as root by doing:</p>
  <pre class="lang-none prettyprint-override"><code># mysql -u root
  </code></pre>
  <p>I get the following error message:</p>
  <pre class="lang-none prettyprint-override"><code>ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
  </code></pre>
  <p>I checked and <code>/var/run/mysqld/mysqld.sock</code> file doesn't not exist. The folder does, but not the file.</p>
  <p>Also, I don't know if this helps or not, but I ran <code>find / -name mysqld</code> and it came up with:</p>
  <pre class="lang-none prettyprint-override"><code>/var/run/mysqld - folder
  /usr/sbin/mysqld - file
  /run/mysqld - folder
  </code></pre>
  <p>I'm new to Linux and MySQL, so I don't know if this is normal or not. But I'm including this info just in case it helps.</p>
  <p><strong>I finally decided to uninstall and reinstall mysql.</strong></p>
  <pre class="lang-none prettyprint-override"><code>apt-get remove mysql-server
  apt-get remove mysql-client
  apt-get remove mysql-common
  apt-get remove phpmyadmin
  </code></pre>
  <p>After reinstalling all packages again in the same order as above, during the phpmyadmin install, I got the same error:</p>
  <pre class="lang-none prettyprint-override"><code>ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
  </code></pre>
  <p>So I tried again to uninstall/reinstall. This time, after I uninstalled the packages, I also manually renamed all mysql files and directories to <code>mysql.bad</code> in their respective locations.</p>
  <pre class="lang-none prettyprint-override"><code>/var/lib/mysql 
  /var/lib/mysql/mysql
  /var/log/mysql
  /usr/lib/perl5/DBD/mysql
  /usr/lib/perl5/auto/DBD/mysql
  /usr/lib/mysql
  /usr/bin/mysql
  /usr/share/mysql
  /usr/share/dbconfig-common/internal/mysql
  /etc/init.d/mysql
  /etc/apparmor.d/abstractions/mysql
  /etc/mysql
  </code></pre>
  <p>Then I tried to reinstall <code>mysql-server</code> and <code>mysql-client</code> again.  But I've noticed that it doesn't prompt me for a password.  Isn't it supposed to ask for an admin password?</p>