title: Authentication String of Root User on MySQL
body: <p>I have spent a lot of time trying to figure this out and have finally reached quite close to the solution as pointed out in this article:</p>
  
  <p><a href="https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/" rel="nofollow noreferrer">https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/</a></p>
  
  <p>Especially this line:</p>
  
  <pre><code>ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';
  </code></pre>
  
  <p>But, when I run this on my command line I get the following:</p>
  
  <pre><code>mysql&gt; ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';
  
  ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'localhost'
  </code></pre>
  
  <p>Further down below in this article there is a comment by someone:</p>
  
  <hr>
  
  <p>If the commande <code>“ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘test’;” doesn’t work you can try :</code></p>
  
  <pre><code>UPDATE mysql.user SET authentication_string = PASSWORD(‘test’), plugin = ‘mysql_native_password’ WHERE User = ‘root’ AND Host = ‘localhost’;
  </code></pre>
  
  <p>FLUSH PRIVILEGES;</p>
  
  <hr>
  
  <p>When I try this I get the following:</p>
  
  <p>mysql> </p>
  
  <pre><code>UPDATE mysql.user SET authentication_string = PASSWORD(‘test’), plugin = ‘mysql_native_password’ WHERE User = ‘root’ AND Host = ‘localhost’;
  ERROR 1054 (42S22): Unknown column '‘root’' in 'where clause'
  </code></pre>
  
  <hr>
  
  <p>I can see the problem that my root user has no password set.  That is why I cannot login as root and I have combed through all the threads here discussing that without any solution.</p>
  
  <p>Here are some warnings that were helpful to me to find the above resources.</p>
  
  <p><a href="https://i.stack.imgur.com/prota.png" rel="nofollow noreferrer">Root user has no authentication_string set</a></p>
  
  <p><a href="https://gyazo.com/fef2073150114ae487f6a0b3b6cf3f96" rel="nofollow noreferrer">https://gyazo.com/fef2073150114ae487f6a0b3b6cf3f96</a></p>
  
  <p>Any help is much appreciated.</p>
  
  <p>Thanks.</p>
  
  <hr>
  
  <p>Additional information based on questions asked in the comments:</p>
  
  <p>mysql> show create user root@'localhost';
  ERROR 1396 (HY000): Operation SHOW CREATE USER failed for 'root'@'localhost'</p>
  
  <p>Problem that I'm trying to solve is to add a password for root.</p>
  
  <p>Right now I have to run mysql using the following sudo mysql</p>
  
  <p>I can't do something like mysql -u root -p</p>
  
  <p>I get the following output:</p>
  
  <p>tkhara@sandbox:~$ mysql -u root -p
  Enter password:
  ERROR 1698 (28000): Access denied for user 'root'@'localhost'</p>
  
  <p>Because there seems to be no password set for the root user.</p>