mysql 恢复用户

[root@db04 ~]# systemctl stop mysqld
[root@db04 ~]# mysqld_safe --skip-grant-table & #跳过授权表,直接就可以登录mysql
注:一个非常有用的mysql启动参数—— --skip-grant-tables。顾名思义,就是在启动
mysql时不启动grant-tables,授权表 --skip-networking是不让别的用户远程登陆
[root@db02 scripts]# mysql #登录MySQL
#往mysql库的user表中插入root用户
mysql> grant all on . to root@'localhost'; #这条命令不需要执行,直接执行下面的命令
mysql> flush privileges;
mysql 恢复用户
在数据库里执行,把以下的内容粘贴复制进去
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');
mysql 恢复用户

[root@db02 scripts]# mysqladmin -uroot -p1 shutdown
[root@db02 scripts]# systemctl restart mysqld
[root@db02 scripts]# mysql

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章