How to reset root users privileges in MySQL

Friday, January 8, 2016

How to reset root users privileges in MySQL

when ever you lost root user privileges. or you see below error multiple times.

"#1045 - Access denied for user 'root'@'localhost' (using password: YES)"

So How can I restore the MySQL root user’s full privileges? If the GRANT ALL doesn't work.

Don't Worry below steps Help to restore root user privileges.

Step 1:- Stop mysqld
          > /etc/init.d/mysqld stop
         
Step 2:- Start it with the --skip-grant-tables option.
         > /etc/init.d/mysqld start --skip-grant-tables

Step 3:- Connect to the mysqld server with just: mysql,  no -u, -p option required
          > mysql

Step 4:- Use Mysql
         > use mysql;

Step 5:- Update root privileges
           >update 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';

Step 6:- Give All Privileges to user
             GRANT ALL ON *.* TO 'root'@'localhost';

After that, you just need to stop the MySQL and start again.


0 comments:

About This Blog

Lorem Ipsum

  © Copyright 2009 Linux-HelpLine.Blogspot.com

Back to TOP