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

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