MySql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) : <p>I've tried multiple solutions from StackOverflow but haven't had any success.  I'm on Mac OSX (Sierra 10.12.3) trying to create a new database and user.  From terminal I enter:</p>

<pre><code>mysql -u root
</code></pre>

<p>which outputs this error:</p>

<blockquote>
  <p>ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)</p>
</blockquote>

<p>To try and resolve it I stopped mysql from 'System Preferences', then from terminal typed:</p>

<pre><code>sudo mysqld_safe —skip-grant-tables
</code></pre>

<p>I opened a second tab and entered:</p>

<pre><code>mysql -u root
</code></pre>

<p>Then from in mysql:</p>

<pre><code>update mysql.user set password_expired = 'N', authentication_string=PASSWORD('newpassword') where user = 'root';

flush privileges;
</code></pre>

<p>I then restart the computer (killing the process with CMD + C doesn't work).  After restarting, trying <code>mysql -u root</code> still produces the same error.</p>

<p>I am able to access mysql via a MySQL client and a non-root user.</p>

<p>Any help is appreciated.</p>
