mysql 8.0.20 忘記密碼,修改密碼


由於mysql更新較快,8.0對比5.7很多操作有了變化,特別修改密碼,和忘記密碼這一塊已經和以前完全不一樣了。

一、 忘記密碼

1、 在my.cnf 文件中添加skip-grant-tables,然后systemctl restart mysqld
2、 直接mysql 登錄,此時不需要填寫密碼。
3、 update mysql.user set authentication_string=’’ where user=’root’ 清空root用戶密碼。
4、 注釋掉skip-grant-tables,重啟mysql
5、 mysql -uroot 無密碼登錄到root模式。
6、 select user,host from user where user='root';

7、 alter user ‘root@’localhost’ identified by ‘password’;
8、 flush privileges; 刷新權限

二、 修改密碼
見上邊第7步

三、 遠程登錄
1、 select user,host from mysql.user where user='user'; 查找用戶名的登錄狀態

2、 修改host登錄主機update mysql.user set host='%' where user='root';
%:表示所有主機可以登錄,可以更改為ip地址
3、 查看權限

4、 flush privileges; 刷新權限


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM