title: How do I reset my root password in MySQL?
body: <p>I'm having trouble connecting to MySQL with from Ubuntu 16.04:</p>
  
  <pre><code>mysql -u root -p
  </code></pre>
  
  <p>which returns the error:</p>
  
  <pre><code>ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
  </code></pre>
  
  <p>When I try starting the server with: </p>
  
  <pre><code>sudo service mysql start
  mysqld_safe --skip-grant-tables &amp;
  </code></pre>
  
  <p>the output is:</p>
  
  <pre><code># 2017-01-26T20:11:45.329764Z mysqld_safe Logging to syslog.
  2017-01-26T20:11:45.333031Z mysqld_safe Logging to '/var/log/mysql/error.log'.
  2017-01-26T20:11:45.336684Z mysqld_safe Logging to '/var/log/mysql/error.log'.
  2017-01-26T20:11:45.358956Z mysqld_safe A mysqld process already exists
  </code></pre>
  
  <p>If I kill the process with:</p>
  
  <pre><code>ps aux | grep "msyql"
  kill -9 pid
  </code></pre>
  
  <p>and then run:</p>
  
  <pre><code>mysqld_safe --skip-grant-tables &amp;
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>2017-01-26T20:10:07.979813Z mysqld_safe Logging to '/var/log/mysql/error.log'.
  2017-01-26T20:10:07.984114Z mysqld_safe Logging to '/var/log/mysql/error.log'.
  2017-01-26T20:10:07.987546Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.
  </code></pre>
  
  <p>It's an endless loop. So then what if I reinstalled from scratch?</p>
  
  <p>First remove MySQL:</p>
  
  <pre><code>sudo apt-get remove --purge mysql-server mysql-client mysql-common
  sudo apt-get autoremove
  sudo apt-get autoclean
  </code></pre>
  
  <p>Then reinstall:</p>
  
  <pre><code>sudo apt-get update
  sudo apt-get install mysql-server
  sudo mysql_install_db   // (deprecated command)
  sudo /usr/bin/mysql_secure_installation 
  </code></pre>
  
  <p>As far as here:</p>
  
  <pre><code>sudo /usr/bin/mysql_secure_installation
  
  Securing the MySQL server deployment.
  
  Enter password for user root:
  Error: Access denied for user 'root'@'localhost' (using password: YES)
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>mysqladmin -u root password [newpass]
  mysqladmin: connect to server at 'localhost' failed
  error: 'Access denied for user 'root'@'localhost' (using password: NO)'
  </code></pre>
  
  <p>Then it falls down.</p>
  
  <p>I've tried following all of the answers here - <a href="https://stackoverflow.com/questions/21944936/error-1045-28000-access-denied-for-user-rootlocalhost-using-password-y">ERROR 1045 (28000): Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: YES)</a></p>
  
  <p>Sometimes a temporary password is stored according to others, but it's not stored in /var/log/mysqld.log as suggested </p>
  
  <p>Anybody able to help?</p>