I accidentally deleted the root user on my local dev setup of MAMP/MySQL running on OS X. There are no other users created to get back into MySQL.
Thi
using mamp. I made the apparently common mistake of deleting the root user when creating another user, I was locked out!
so I found this post and tried to follow the directions but...
I was getting this errores: -bash: mysql: command not found when trying to execute the command mysql commands and later I was getting this error DELETE command denied to user ''@'localhost' for table 'user' when tring to set properly privileges to the root user and do anything with that user once mysql in shell.
so before I could use the commands eric and rolando posted (thank you guys for that) this is what I did
I need to start mysqld properly so I had to do the following
ps aux | grep mysql
kill -9 [pid]
/Applications/MAMP/Library/bin/mysqld --skip-grant-tables --skip-networking &
I tried with my.cnf file but couldn't get it to work.
/Applications/MAMP/Library/bin/mysql -u root -p
(if prompted for a password just hit enter)
then execute the commands eric and rolando posted, this time I didnt get any error "DELETE command denied to user ''@'localhost' for table 'user'" if you do, you didn't start mysqld properly
then stop the mysqld service:
/Applications/MAMP/Library/bin/mysqld stop
then restarted mamp as usual with the gui
and all started to work again as it was before... I was so relieved!!!
2 hours of panic and trial and error with the console... valuable lessons learned..
If I messed up any of the commands or the explanation (which could be the case as I was tracing my steps back as writing this post please let me know. I'd be happy to update the post.
lastly don't give. it can be done!!