CENTOS7安裝MYSQL5.7出現1045錯誤沒辦法登入MYSQL解決方法


在登錄mysql時,有時會出現1045錯誤,這個密碼或或用戶名錯誤
解決方案:
第一種方式:

  1. grep 'temporary password' /var/log/mysqld.log
  2. Run mysql_secure_installation to change new password

第二種方式:
1、修改/etc/my.cnf,在[mysqld]下加入 skip-grant-tables
2systemctl restart mysqld  à重新啟動mysql服務。
3、此時登錄mysql就不需要密碼了。在cmd中輸入mysql -u root -p登錄資料庫
4、進入MYSQL命令模式 輸入use mysql;
5、輸入update user set authentication_string=password('123qwe') where user='root';注意最後的分號不能漏,否則sql語句無效。authentication_string5.7之前是password5.7之後是setauthentication_string
6、輸入更新資料庫指令,flush privileges;
7、輸入退出mysql指令:quit

8、改好之後,把/tc/my.cnf,把剛剛加入的”skip-grant-tables”這行刪除,存檔退出再重新啟動 systemctl restart mysql就可以了


留言

這個網誌中的熱門文章

java 數字轉字串 字串轉數字

MS sqlServer資料庫移轉至MySQL-->利用MySQL WorkBench

sql server 15023 error [SQL SERVER問題: 使用者、組或角色 '*****' 在當前資料庫中已存在]