title: setting mysql root password in CentOS linux
body: <p>I installed MySQL on CentOS linux and am trying to set the root password.  Towards this end, I took the following steps:  </p>
  
  <pre><code>1.) I opened the terminal and typed in `su - ` to run as root.  
  2.) I then ran `mysql - u root`, which resulted in a lot of output and another prompt.  
  3.) I then typed in `UPDATE mysql.user SET Password=PASSWORD('NewPassHere')  
      WHERE User='root';`  
  </code></pre>
  
  <p>But step 3 produced the following error:  </p>
  
  <pre><code>-bash: syntax error near unexpected token `('
  </code></pre>
  
  <p>When I change step 3 to <code>UPDATE mysql.user SET Password='NewPassHere' WHERE User='root';</code>, I get the following error:  </p>
  
  <pre><code>bash: UPDATE: command not found...
  </code></pre>
  
  <p><strong>How can I resolve this error so that I can set the root password in MySQL successfully?</strong>  </p>
  
  <hr>
  
  <p>Based on Chuck's suggestion, I tried the following, but got the following results:  </p>
  
  <pre><code>[root@localhost ~]# /usr/bin/mysqladmin -u root password 'newpwd'
  /usr/bin/mysqladmin: connect to server at 'localhost' failed
  error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
  Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
  </code></pre>
  
  <p>The following two commands also had the following two results:  </p>
  
  <pre><code>[root@localhost ~]# sudo service mysqld status
  Redirecting to /bin/systemctl status  mysqld.service
  mysqld.service
     Loaded: not-found (Reason: No such file or directory)
     Active: inactive (dead)
  
  [root@localhost ~]# sudo service mysqld start
  Redirecting to /bin/systemctl start  mysqld.service
  Failed to issue method call: Unit mysqld.service failed to load: No such file or directory.
  </code></pre>
  
  <hr>
  
  <p><strong>ANSWER:</strong>  </p>
  
  <hr>
  
  <p>The solution to this problem was to delete mysql using yum remove and then to follow <a href="http://sharadchhetri.com/2014/07/31/how-to-install-mysql-server-5-6-on-centos-7-rhel-7/" rel="nofollow">the steps in this tutorial</a> explicitly.  However, I am marking Chuck's answer below as accepted because he spent so much time looking into this.</p>