Karl Bao
Karl Bao

Reputation: 431

How can I grant all privileges to root@localhost in MySQL?

I'm using WAMP and I accidentally disable the DELETE privilege from phpMyAdmin GUI.

enter image description here

I have tried many ways like mysql_upgrade and change password. However, I still get the error #1045: Access denied for user root@localhost when I am trying to add the DELETE privilege.

How can I grant the full privileges back to root@localhost?

enter image description here

Upvotes: 2

Views: 13362

Answers (2)

Abel
Abel

Reputation: 548

Something like this should work for you:

  1. Add skip-grant-tables in my.cnf file under the [mysqld] section or otherwise stop mysqld and start it with the --skip-grant-tables option.
  2. Use mysql to connect to DB without password without -p
  3. Then execute this:

    UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root'; FLUSH PRIVILEGES;

  4. Then execute: GRANT ALL ON *.* TO 'root'@'localhost';

Upvotes: 5

Ivan Cachicatari
Ivan Cachicatari

Reputation: 4294

Edit your my.ini configuration file usually located at Drive:\wamp\bin\mysql\mysql-x.x\my.ini

Add this line in the [mysql] section:

[mysqld]
skip-grant-tables

Restart your MySQL server and restore the user permissions, after that remove that line and restart MySQL.

Upvotes: 0

Related Questions