title: Set up MySQL: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
body: <p>I was trying to set up MySQL with Django.</p>
  
  <p>Environment: Ubuntu 14.04 with Python 2.7 and 3.4 preinstalled (default is 3.4) and Django: 1.8.4.</p>
  
  <p>I set it up following <a href="https://www.digitalocean.com/community/tutorials/how-to-use-mysql-or-mariadb-with-your-django-application-on-ubuntu-14-04" rel="nofollow noreferrer">this tutorial</a></p>
  
  <p>1) Install sql and set admin password through the prompt window</p>
  
  <pre><code>sudo apt-get update
  sudo apt-get install python-pip python-dev mysql-server libmysqlclient-dev
  </code></pre>
  
  <p>2) Create database directory</p>
  
  <pre><code>sudo mysql_install_db
  </code></pre>
  
  <p>3) Run through security script and said yes for all question except the one asked me for new password</p>
  
  <pre><code>sudo mysql_secure_installation
  </code></pre>
  
  <p>Then I tried to logging into an interactive session with the following command:</p>
  
  <pre><code>mysql -u root -p
  </code></pre>
  
  <p>The problem came, it says</p>
  
  <pre><code>ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
  </code></pre>
  
  <p>I searched online for this, but couldn't find the same situation or possible solution.</p>
  
  <p>It's my first time tring to set up database for web framework, any suggestions are welcome! I'll be super greatful it there is any easy-to-follow tutorial that could help me through this process!</p>
  
  <p>Thanks in advance!</p>
  
  <p><br><br></p>
  
  <p><strong>Update</strong>:</p>
  
  <p>I solved this problem by referring to <a href="https://superuser.com/questions/603026/mysql-how-to-fix-access-denied-for-user-rootlocalhost">this post</a>. But I have to add sudo while restarting mysql.</p>
  
  <pre><code>$ sudo /etc/init.d/mysql restart
  </code></pre>