mysql 误删除所有用户或者忘记root密码

/etc/init.d/mysqld stop //停止数据库
/etc/init.d/mysqld restart //启动数据库
(1)开启特殊启动模式
mysqld_safe --skip-grant-tables --skip-networking &    //跳过授权,直接登陆mysql不需要密码

--skip-grant-tables //跳过授权

INSERT INTO mysql.user VALUES ('localhost',root,PASSWORD('123'),'Y','Y','Y','Y','Y',
'Y','Y','Y','Y','Y',
'Y','Y','Y','Y','Y',
'Y','Y','Y','Y','Y',
'Y','Y','Y','Y','Y',
'Y','Y','Y','Y','',
'','','',0,0,0,0,
'mysql_native_password','','N');

猜你喜欢

转载自www.cnblogs.com/nyfz/p/9665028.html