0

I was clicking around PhpMyAdmin, and I accidentally removed all the privileges for the root user facepalm

So now, when I am in PhpMyAdmin, I have no privileges to do anything at all. How can I reset the privileges for the root user?

(MySQL was installed through MAMP)

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
Jamie Wade
  • 277
  • 3
  • 19

1 Answers1

2

It depends on what operating system you are running, but you need to kill the MySQL service and relaunch it skipping the grant tables.

On OSX with MAMP

  • Shutdown MAMP all together, this will ensure that MySQL is not running
  • Then enter the following command to start MySQL with the right permissions

/Applications/MAMP/Library/libexec/mysqld --skip-grant-tables --port=8889 --socket=/Applications/MAMP/tmp/mysql/mysql.sock

  • Then launch mysql command line utility to update priviledges

mysql -u root

In *nix:

mysqld --skip-grant-tables

Then run mysql to get into the command prompt

mysql -u root

Once in MySQL Command Line

Once running in skip grant tables mode, you can run a command to update the user privileges.

UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';
FLUSH PRIVILEGES;
  • Thanks Devyn, I am running OS X Mavericks. I'm afraid I'm a complete beginner with MySQL, so how will I kill the MySQL service and where do I put the command script? – Jamie Wade Mar 10 '14 at 20:57
  • Still no luck I'm afraid. Do I run 'mysqld --skip-grant-tables' from Terminal? – Jamie Wade Mar 10 '14 at 21:22
  • Yes. The idea is to kill the server (but shutting down MAMP), then run the command listed above in a terminal. It will start a MySQL service ignoring all privileges. You cannot edit from PHPMyAdmin though. You have to run the command above in the command line utility for MySQL. – Devyn Cunningham Mar 10 '14 at 21:31
  • Still nothing unfortunately. In the first command you sent, I presume /Library/libexec/ is meant to be /Library/bin/ ? As there is no libexec folder? – Jamie Wade Mar 10 '14 at 21:45