一次docker登錄mysql報錯問題的實戰(zhàn)記錄
起因
最近想再重溫重溫MySQL,于是就打開VMware登上了我的小破機。想著之前在docker上面已經裝過MySQL了,就嘗試著登錄了一下,
進入mysql服務
docker exec -it mysql bash
輸入命令
mysql -uroot -p
輸入密碼
想象的Welcome to the MySQL沒有到來,反而是
???密碼明明沒有錯,登不上去.....
之后打開Navicat,測試遠程登錄,??登上去了,Navicat可以正常使用。
那為什么命令行卻登不上去?
找了好多資料才知道原來是MySQL密碼加密插件的原因,MySQL最新的8.0.x
版本使用的時默認的caching_sha2_password插件,而MySQL5.x的版本使用的是mysql_native_password插件。
使用命令行明文密碼登錄的時候,走的是mysql_native_password,數(shù)據(jù)庫中存的是caching_sha2_password加密過的密碼,所以兩者自然不匹配。
解決方法
可以先通過以下SQL語句查詢確認。
select user, plugin from mysql.user;
在通過以下SQL進行修改:
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password'; FLUSH PRIVILEGES;
語句中的用戶:root,host:%,密碼找按實際情況修改。
解決之后,再次登錄MySQL,就可以登進去了。
附:docker下進入mysql命令行
[root@VM_0_8_centos ~]# docker exec -it 89c5b9c81e74 bash root@89c5b9c81e74:/# mysql -u root -p
Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 141019 Server version: 5.7.18 MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
總結
到此這篇關于docker登錄mysql報錯問題的文章就介紹到這了,更多相關docker登錄mysql報錯內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
- docker 命令報異常permission denied的解決方案
- docker容器因報錯無法啟動問題的檢查及修復容器錯誤并重啟
- Docker報錯Operation?not?permitted問題的解決方法
- Docker啟動失敗報錯Failed?to?start?Docker?Application?Container?Engine的解決辦法
- Docker報錯:OCI?runtime?exec?failed:?exec?failed:?container_linux.go:380:?starting?container?process的解決方法
- Docker報錯denied:requested access to the resource is denied解決
相關文章
mysql報錯RSA?private?key?file?not?found的解決方法
當MySQL報錯RSA?private?key?file?not?found時,可能是由于MySQL的RSA私鑰文件丟失或者損壞導致的,此時可以重新生成RSA私鑰文件,以解決這個問題2023-06-06MySQL使用ReplicationConnection導致連接失效解決
這篇文章主要為大家介紹了MySQL使用ReplicationConnection導致連接失效問題分析解決,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-07-07mysql啟動的error 2003和1067錯誤問題解決方法
mysql安裝好經常發(fā)現(xiàn)無法正常啟動碰到最多的是error 2003的錯誤,經研究在此附上解決方法,希望可以幫助有類似問題的朋友2013-09-09mysql 一個較特殊的問題:You can''t specify target table ''wms_cabinet
mysql 一個較特殊的問題:You can't specify target table 'wms_cabinet_form' for update in F2010-11-11