Home / Bản tin tổng hợp / Thư giãn / recover deleted root user in mysql

recover deleted root user in mysql

 

  1. If mysql service is already running, stop it.
  2. Run cmd command – press: windows + R, type cmd – enter and goto MYSQL_HOME/bin directory.
  3. Run following commands
    1. > mysqld –skip-grant-tables
  4. Run cmd command – press: windows + R, type cmd – enter and goto MYSQL_HOME/bin directory.
  5. Run following commands
    1. > mysql –u=root
  6. (DO NOT TAKE THIS: > GRANT CREATE, DROP ON *.* TO [email protected] IDENTIFIED BY 'newpass' WITH GRANT OPTION;> GRANT ALL PRIVILEGES ON *.* TO [email protected] IDENTIFIED BY 'newpass' WITH GRANT OPTION;) - IT'S NOT WORKING FOR YOU AND WASTE YOUR TIMES
  7. TAKE THIS:
DELETE FROM mysql.user WHERE user='root' AND host='localhost';
INSERT INTO mysql.user SET
                  Host = 'localhost',
                  User = 'root',
              Password = PASSWORD(''),
           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',
              ssl_type = '',
              ssl_cipher = '',
             x509_issuer = '',
            x509_subject = '',
           max_questions = 0,
             max_updates = 0;

8. NEXT RUN COMMAND: service mysql restart

LOGIN TO PHPMYADMIN BY LOCALHOST AND ENJOY 🙂

Trả lời

Thư điện tử của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

Đăng ký nhận bản tin