title: Correct mysql syntax error when creating a user
body: <p>So im getting the very common <code>ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)</code> mysql error. I have tried all of the typical fixes on the forums, logging in via the mysql_safe method and then trying to reset my root password. However when doing so it returns with;</p>
  
  <pre><code>UPDATE user SET password=PASSWORD("PASSWORD")WHERE user="root";
  Query OK, 0 rows affected (0.00 sec)
  Rows matched: 0  Changed: 0  Warnings: 0
  </code></pre>
  
  <p>So as no rows were affected I assumed there was no user to actually change. I tried to create a user:</p>
  
  <pre><code>CREATE USER 'root'@'localhost' IDENTIFIED BY 'root'
      -&gt; GRANT ALL ON *.* TO 'root'@'localhost'
      -&gt; flush privileges;
  
  However this returns with ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GRANT ALL ON *.* TO 'root'@'localhost'
  </code></pre>
  
  <p>Seeing what the current user is:</p>
  
  <pre><code>mysql&gt; SELECT user();
  +--------+
  | user() |
  +--------+
  | root@  | 
  +--------+
  </code></pre>
  
  <p>I assume the syntax error is the fact that nothing comes after the @ after "root". How can i edit this information to be root@localhost and correct the issue?</p>
  
  <p>UPDATE</p>
  
  <p>after carefully reading the mysqld docs i got to this section which worked perfectly.</p>
  
  <p>Stop mysqld and restart it with the --skip-grant-tables option. This enables anyone to connect without a password and with all privileges. Because this is insecure, you might want to use --skip-grant-tables in conjunction with --skip-networking to prevent remote clients from connecting.</p>
  
  <p>Connect to the mysqld server with this command:</p>
  
  <pre><code>shell&gt; mysql
  </code></pre>
  
  <p>Issue the following statements in the mysql client. Replace the password with the password that you want to use.</p>
  
  <pre><code>mysql&gt; UPDATE mysql.user SET Password=PASSWORD('MyNewPass')
      -&gt;                   WHERE User='root';
  mysql&gt; FLUSH PRIVILEGES;
  </code></pre>
  
  <p>The FLUSH statement tells the server to reload the grant tables into memory so that it notices the password change.</p>