简体   繁体   中英

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.

在此处输入图片说明

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?

在此处输入图片说明

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';

Edit your my.ini configuration file usually located at Drive:\\wamp\\bin\\mysql\\mysql-xx\\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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM