2

Mysql 8 root user all privileges lost.I changed some permissions from phpmyadmin.

. After that all tables disappeared. I found this answer Lost All Privileges in MYSQL.but did'nt help me.

I am using Wampserver 3.2 on windows 7 and mysql version is 8.0.18 Now showing only information_schema table. I login as root user and run all below commands.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
+--------------------+

mysql> use mysql;
ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'mysql;

mysql> SELECT user, host FROM mysql.user;
ERROR 1142 (42000): SELECT command denied to user 'root'@'localhost' for table '
user';

mysql> SHOW GRANTS;
+--------------------------------------------------------------+
| Grants for root@localhost                                    |
+--------------------------------------------------------------+
| GRANT USAGE ON *.* TO `root`@`localhost`                     |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION |
+--------------------------------------------------------------+

How to revoke all privileges for 'ROOT' user

Please help

1

1 Answer 1

3

Thank god,Finally it worked out. first I created a file named as mysql-init.txt in c drive.The file contains

update mysql.user
set Select_priv='Y',
    Insert_priv='Y',
    Update_priv='Y',
    Delete_priv='Y',
    Create_priv='Y',
    Drop_priv='Y',
    Reload_priv='Y',
    Shutdown_priv='Y',
    Process_priv='Y',
    File_priv='Y',
    Grant_priv='Y',
    References_priv='Y',
    Index_priv='Y',
    Alter_priv='Y',
    Show_db_priv='Y',
    Super_priv='Y',
    Create_tmp_table_priv='Y',
    Lock_tables_priv='Y',
    Execute_priv='Y',
    Repl_slave_priv='Y',
    Repl_client_priv='Y',
    Create_view_priv='Y',
    Show_view_priv='Y',
    Create_routine_priv='Y',
    Alter_routine_priv='Y',
    Create_user_priv='Y',
    Event_priv='Y',
    Trigger_priv='Y' 
where User='root';

Then I run this command.

D:\wamp3\bin\mysql\mysql8.0.18\bin>mysqld --init-file=c:\\mysql-init.txt --conso
le

Then login as root user.Now all database showing up.

1
  • a better way is a grant all on *.* root@localhost with grant option in the init-file. But glad it worked for you.
    – danblack
    Commented Apr 1, 2020 at 23:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.