On PhpMyAdmin, I removed 'root' user by mistake. I was also logged in as 'root'. How can I add the user 'root' back, on MAMP?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
Assuming you went with a generic install of MySQL, my procedure for MAMP is:
1. Edit your my.cnf, probably located at: /usr/local/my.cnf, adding the lines:
2. Restart mysqld
3. Change root privs
4. Remove the skip lines from the my.cnf
5. Restart mysqld again
DISCLAIMER : Not a MacOS user
Here is something quick-and-dirty and very secure.
Step 01) Create a script to create user
If root had a password (such as
If root had no password, run this
Step 02) Restart mysql using the init.sql file
Step 03) Remove /var/lib/mysql/init.sql
All Done !!! No need to use skip-networking or skip-grant-tables.
In the past, I used to recommend restarting mysql twice.
@Shlomi Noach's answer had a one-restart approach, which I now recommend to others.
Give it a Try !!!