title: MAMP mysql broken root user
body: <p>I've read many threads on SO and a few other places and haven't been able to fix my mysql installation in MAMP.</p>
  
  <p>Background.  I made a change to my root user the other day in an attempt to get a local service to connect properly.  After rebooting my machine phpmyadmin in mamp no longer displayed any of my dbs and showed "No Privileges" to create a database.  I tried many things to restore the privileges that I read here and elsewhere to no avail.  --skip-grant-tables does not seem to work.  Connecting as root in the shell I don't have permission as localhost but I do as 127.0.0.1.</p>
  
  <pre><code>show grants for root@localhost;
  GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
  </code></pre>
  
  <p>I've installed a fresh installation of MAMP and copied over my DBs.  While it works, I've run into instances where DBs are not showing all the tables.</p>
  
  <p>So I have to solve one of two problems.  I either have to fix the original install or make it so the all tables show for my dbs in my fresh mamp install.</p>
  
  <p>Lesson learned here is don't be lazy and screw around with your root user locally and just create another login.</p>
  
  <p>UPDATE
  When I connect as:</p>
  
  <pre><code>/Applications/MAMP/Library/bin/mysql -uroot -h127.0.0.1 -p
  mysql&gt; SHOW GRANTS FOR 'root'@'localhost';
  +------------------------------------------------------------------------+
  | Grants for root@localhost                                              |
  +------------------------------------------------------------------------+
  | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION    | 
  | GRANT ALL PRIVILEGES ON `db`.* TO 'root'@'localhost' WITH GRANT OPTION | 
  +------------------------------------------------------------------------+
  </code></pre>
  
  <p>But when I connect as:</p>
  
  <pre><code>/Applications/MAMP/Library/bin/mysql -uroot -hlocalhost -p
  mysql&gt; SHOW GRANTS FOR 'root'@'localhost';
  ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
  mysql&gt; SELECT user();
  +----------------+
  | user()         |
  +----------------+
  | root@localhost | 
  +----------------+
  mysql&gt; SELECT current_user();
  +----------------+
  | current_user() |
  +----------------+
  | @localhost     | 
  +----------------+
  </code></pre>
  
  <p>So when I connect as localhost either by IP or socket I am somehow not logged in as root.  I find this very confusing?</p>