ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in Vagrant
<p>I have a problem with my mysql-server in vagrant. Everytime i restart my vagrant box with <br><code>vagrant reload</code> or <code>vagrant up</code> i get this confusing error. <br><br>My vagrant box is this one here: <code>ubuntu/trusty64</code> from 
<a href="https://atlas.hashicorp.com/ubuntu/boxes/trusty64" rel="nofollow noreferrer">Vagrant-Boxes</a><br><br>This error has been answered already several times here and at askubuntu. <br>but i want to know why only this code works for me:</p>

<pre><code>su - mysql -s /bin/sh -c "/usr/bin/mysqld_safe &gt; /dev/null 2&gt;&amp;1 &amp;"
</code></pre>

<p>the code is from the file <code>mysql*</code> at <code>/etc/init.d/mysql</code>.<br><br>
can anyone explain what the code means?
<br><br>
all this answeres did <strong>not</strong> help me for explanation from here:<br>
<br><a href="https://stackoverflow.com/questions/22290519/mysql-error-2002-hy000-cant-connect-to-local-mysql-server-through-socket-v">mysql ERROR 2002 (HY000): Can&#39;t connect to local MySQL server through socket &#39;/var/run/mysqld/mysqld.sock&#39; (2)</a> <br><a href="https://stackoverflow.com/questions/39861733/error-2002-hy000-cant-connect-to-local-mysql-server-through-socket-var-run">ERROR 2002 (HY000): Can&#39;t connect to local MySQL server through socket &#39;/var/run/mysqld/mysqld.sock&#39;</a> <br><a href="https://stackoverflow.com/questions/11657829/error-2002-hy000-cant-connect-to-local-mysql-server-through-socket-var-run">ERROR 2002 (HY000): Can&#39;t connect to local MySQL server through socket &#39;/var/run/mysqld/mysqld.sock&#39; (2)</a></p>