安裝mysql8
安裝借鑑官方文檔以及其他博友的文章
下面開始贅述遇到的坑,還有解決辦法,希望能對大家有用
- 重置密碼的問題
按照文檔修改默認密碼後,然後再次登錄,提示登錄失敗
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
我的操作流程是,按文檔走的
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
然後修改可以然所有用戶登錄的權限
update user set host='%' where user='root';
後來退出再重新登錄一直總是提示
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
試過很多辦法無法解決,特別是在user表中沒有了password這一列
解決辦法
感謝博友提供解決方案mysql8重置密碼的問題
vim /etc/my.cnf
在末尾加入 skip-grant-tables 後,不驗證密碼
然後
use mysql;
update user set authentication_string=” where user=’root’;
將 authentication_string置空接下來就註釋掉 /etc/my.cnf 文件裏的 skip-grant-tables
service mysqld restart
mysql -uroot -p
不用輸入密碼直接按回車鍵
登錄成功
ALTER user ‘root’@’%’ IDENTIFIED BY ‘Newpassword!’;
注意我這是 ‘root’@’%’
坑點在與之前是’root’@’localhost’ 修改的密碼,後來
update user set host=’%’ where user=’root’;
改成了’root’@’%’ 退出後密碼就不能登錄了
坑點二,卸載重新安裝後使用默認密碼都不能登錄
因爲除了卸載完rpm 包,沒有刪除所有mysql文件
find / -name mysql
rm -rf 文件名
感謝網友的分享,所以分享很重要,希望能解決大家遇到的坑