MySQL User table root users mistakenly deleted after recovering the root user
Method/Step
1. Stop the MySQL service; Locate the My.ini in the MySQL installation directory, locate the following fragment in the My.ini [mysqld], and add another line to the code: Skip-grant-tables and save
2. Start the MySQL service and log in to MySQL (no username and password); Find user table join root user insert into Host,user,password VALUES (' localhost ', ' root ', Password (' 123456 '));
3, root user set permissions update user set host= ' localhost ', select_priv= ' y ', insert_priv= ' y ', update_priv= ' y ', alter_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 ', create_user_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 ' where user= ' Root '; commit;
4. Delete the line that My.ini just joined and restart the service
5, log in with the root user, ok!
Mysql User table root deleted by mistake after recovery