ROOT账户误删后恢复指南

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

--1 杀掉你的MYSQLD进程
/etc/init.d/mysqld stop

--2 进入MYSQL的bin目录,以不验证权限的方式启动MYSQL
cd /usr/local/mysql/bin
./mysqld_safe --skip-grant-tables &

--3 新起进程登录MYSQL
./mysql

--4 尽量别用ROOT账户名,创建admin用户
insert into mysql.user set user='admin',ssl_cipher='',host='%',password=password("password"), x509_issuer='', x509_subject='';

--5 赋予权限
update mysql.user set Host='%',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='admin';

--6 加载新的权限
flush privileges;

--7 杀掉 safe 模式的mysql进程
killall mysqld

--8 启动MYSQL
/etc/init.d/mysqld start