HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

How to add 'root' MySQL user back on MAMP?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
usermampbackmysqlroothowadd

Problem

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?

Solution

MySQL's suggested procedures

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:



skip-grant-tables
skip-networking


  1. Restart mysqld



sudo su -
/usr/local/mysql/bin/mysqladmin shutdown
nohup /usr/local/mysql/bin/mysqld_safe &
exit


  1. Change root privs



`mysql> GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY 'password' WITH GRANT OPTION;`


  1. Remove the skip lines from the my.cnf



## skip-grant-tables
## skip-networking


  1. Restart mysqld again



sudo su -
/usr/local/mysql/bin/mysqladmin shutdown
nohup /usr/local/mysql/bin/mysqld_safe &
exit

Code Snippets

skip-grant-tables
skip-networking
sudo su -
/usr/local/mysql/bin/mysqladmin shutdown
nohup /usr/local/mysql/bin/mysqld_safe &
exit
`mysql> GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY 'password' WITH GRANT OPTION;`
## skip-grant-tables
## skip-networking
sudo su -
/usr/local/mysql/bin/mysqladmin shutdown
nohup /usr/local/mysql/bin/mysqld_safe &
exit

Context

StackExchange Database Administrators Q#33468, answer score: 2

Revisions (0)

No revisions yet.