title: How to recover mysql root password in MacOS
body: <p>I start my MAMP and try to connect to my MySQL server via <code>localhost</code> or <code>127.0.0.1</code>, I tried all the possible password that I think it is correct, but for some reasons it still didn't like it, so I think I forgot it somehow. I need help.</p>
  
  <hr>
  
  <h1>Try #1</h1>
  
  <p>Enter all the possible passwords</p>
  
  <p><code>MySQL -u root -h localhost -p</code></p>
  
  <p>Enter password: &lt;---<em>I've tried almost 10 possible passwords</em></p>
  
  <p>I got </p>
  
  <blockquote>
    <p>ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)</p>
  </blockquote>
  
  <hr>
  
  <h1>Try #2</h1>
  
  <p>Enter possible passwords</p>
  
  <p><code>MySQL -u root -h localhost</code></p>
  
  <p>I got </p>
  
  <blockquote>
    <p>ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)</p>
    
    <hr>
  </blockquote>
  
  <h1>Try #3</h1>
  
  <p><code>MySQL.server stop</code></p>
  
  <p>I got </p>
  
  <blockquote>
    <p>ERROR! MySQL server PID file could not be found!</p>
  </blockquote>
  
  <p>I'm trying to run this</p>
  
  <p><code>mysqld_safe --skip-grant-tables &amp;</code></p>
  
  <p>I got </p>
  
  <hr>
  
  <h1>Try #4</h1>
  
  <p><code>mysqld_safe --skip-grant-tables &amp;</code></p>
  
  <p>I got </p>
  
  <pre><code>[1] 72194
    ~  2017-10-04T12:13:42.6NZ mysqld_safe Logging to '/usr/local/var/mysql/BH-MacBook-Pro-15-512GB.local.err'.
  2017-10-04T12:13:42.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
  2017-10-04T12:13:44.6NZ mysqld_safe mysqld from pid file /usr/local/var/mysql/BH-MacBook-Pro-15-512GB.local.pid ended
  </code></pre>
  
  <p>Open a new tab </p>
  
  <p><code>MySQL -u root</code></p>
  
  <p>I still get </p>
  
  <blockquote>
    <p>ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)</p>
  </blockquote>
  
  <hr>
  
  <h1>Try #5</h1>
  
  <p>Close my MAMP application, and run this </p>
  
  <p><code>mysqld_safe --skip-grant-tables &amp;</code></p>
  
  <p>I got </p>
  
  <pre><code>[1] 72194
    ~  2017-10-04T12:13:42.6NZ mysqld_safe Logging to '/usr/local/var/mysql/BH-MacBook-Pro-15-512GB.local.err'.
  2017-10-04T12:13:42.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
  2017-10-04T12:13:44.6NZ mysqld_safe mysqld from pid file /usr/local/var/mysql/BH-MacBook-Pro-15-512GB.local.pid ended
  </code></pre>
  
  <p>Open a new tab </p>
  
  <p><code>MySQL -u root</code></p>
  
  <p>I still get </p>
  
  <blockquote>
    <p>ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)</p>
  </blockquote>
  
  <hr>
  
  <p>I don't what else to try anymore. </p>
  
  <p><em>I can't really set the root password because I can't even get in.</em></p>
  
  <hr>
  
  <p>This is the process of my MySQL</p>
  
  <p><code>ps aux | grep MySQL</code></p>
  
  <pre><code>bheng            95850   0.2  1.0  2869440 175404   ??  S     8:48AM   0:00.28 /usr/local/opt/mysql/bin/mysqld --basedir=/usr/local/opt/mysql --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/opt/mysql/lib/plugin --bind-address=127.0.0.1 --log-error=/usr/local/var/mysql/bh-mbp-15-512gb.ad.benu.net.err --pid-file=/usr/local/var/mysql/bh-mbp-15-512gb.ad.benu.net.pid
  _mysql             124   0.0  0.0  2864848   4040   ??  Ss   22Sep17   0:32.26 /usr/local/mysql/bin/mysqld --user=_mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/usr/local/mysql/data/mysqld.local.err --pid-file=/usr/local/mysql/data/mysqld.local.pid --keyring-file-data=/usr/local/mysql/keyring/keyring --early-plugin-load=keyring_file=keyring_file.so
  bheng            95863   0.0  0.0  2423384    396 s009  R+    8:48AM   0:00.00 grep mysql
  bheng            95749   0.0  0.0  2448756   2496   ??  S     8:48AM   0:00.03 /bin/sh /usr/local/opt/mysql/bin/mysqld_safe --bind-address=127.0.0.1 --datadir=/usr/local/var/mysql
  bheng            66379   0.0  0.1  2696936   9304   ??  S     8:06AM   0:00.51 /Applications/MAMP/Library/bin/mysqld --basedir=/Applications/MAMP/Library --datadir=/Applications/MAMP/db/mysql --plugin-dir=/Applications/MAMP/Library/lib/plugin --log-error=/Applications/MAMP/logs/mysql_error_log.err --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --socket=/Applications/MAMP/tmpmysql/mysql.sock --port=8889
  bheng            66263   0.0  0.0  2446708   2100   ??  S     8:06AM   0:00.02 /bin/sh /Applications/MAMP/Library/bin/mysqld_safe --port=8889 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-error=/Applications/MAMP/logs/mysql_error_log
  </code></pre>
  
  <p>  ~  </p>