#2002 - Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
<p>I was trying to install something on a Ubuntu 14.04 machine, ran <code>sudo apt-get update</code>, then <code>sudo apt-get upgrade</code> and it apparently did something to my MySQL server.</p>
<p>Now I can't start it. I get this error:</p>
<pre><code>#2002 - Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13) — 
The server is not responding (or the local server's socket is not correctly configured).
</code></pre>
<p>I'm not sure if the server is even installed. When I try to restart or start the service it always returns &quot;Job failed!&quot;.</p>
<p>I've purged everything:</p>
<pre><code>$ sudo apt-get remove --purge mysql\*
</code></pre>
<p>and then tried to install it back with</p>
<pre><code>$ sudo apt-get install mysql-server mysql-client
</code></pre>
<p>but it basically ends with this and I'm back to square one.</p>
<pre><code>Preparing to unpack .../mysql-server-5.5_5.5.35+dfsg-1ubuntu1_amd64.deb ...
Aborting downgrade from (at least) 5.6 to 5.5.
If are sure you want to downgrade to 5.5, remove the file
/var/lib/mysql/debian-*.flag and try installing again.
dpkg: error processing archive /var/cache/apt/archives/mysql-server-5.5_5.5.35+dfsg-1ubuntu1_amd64.deb (--unpack):
 subprocess new pre-installation script returned error exit status 1


Errors were encountered while processing:
/var/cache/apt/archives/mysql-server-5.5_5.5.35+dfsg-1ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
</code></pre>
<p>Trying to <em>install mysql-server-5.6</em> and <em>mysql-client-5.6</em> doesn't help either:</p>
<pre><code>start: Job failed to start
invoke-rc.d: initscript mysql, action &quot;start&quot; failed.
dpkg: error processing package mysql-server-5.6 (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up mysql-common-5.6 (5.6.16-1~exp1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.7) ...
Processing triggers for ureadahead (0.100.0-16) ...
Errors were encountered while processing:
 mysql-server-5.6
E: Sub-process /usr/bin/dpkg returned an error code (1)
</code></pre>
<p>I've found so many posts here with the same error message and tried probably all the solutions proposed, but nothing works. Help!</p>
<br />
<h1>SOLVED</h1>
<p>Though, perhaps not in the best way possible.
Here's what I did:</p>
<pre><code>$ sudo -i
# sudo apt-get remove --purge mysql\* 
# cp -R /var/lib/mysql /home/user/backup
# sudo rm -rf /var/lib/mysql/
# sudo rm -rf /etc/mysql
# sudo apt-get autoremove
# sudo apt-get autoclean
# sudo apt-get install mysql-server php5-mysql
</code></pre>
<p>Then I had to restore my backed up databases and finally I got it up and running. I'm so mad at to how much time I lost to this.</p>