mysql sqlyog提示2058錯誤或者用Navicat連接本機Docker的Mysql 和一些問題的解決方案


1. 下載Mysql的Docker鏡像:

[plain] view plain copy
$ docker search mysql (搜索mysql鏡像)  
$ docker pull mysql (下載mysql鏡像,默認最新版本)  
2. 運行鏡像,設置root賬號初始密碼(123456),映射本地宿主機端口3306到Docker端口3306。測試過程沒有掛載本地數據盤:

[plain] view plain copy
$ docker run -it --rm --name mysql -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 -d mysql  
3. 查看已運行的容器:

[plain] view plain copy
$ docker ps -a  
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES  
a42f31094df5        mysql               "docker-entrypoint.s…"   7 seconds ago       Up 6 seconds        0.0.0.0:3306->3306/tcp   mysql  
4. 進入mysql容器:

[plain] view plain copy
docker exec -it mysql bash  
root@a42f31094df5:/#   
5. 在容器內登陸Mysql:

[sql] view plain copy
root@a42f31094df5:/# mysql -uroot -p123456 或 (mysql -uroot -p ) 
mysql: [Warning] Using a password on the command line interface can be insecure.  
Welcome to the MySQL monitor.  Commands end with ; or \g.  
Your MySQL connection id is 9  
Server version: 8.0.11 MySQL Community Server - GPL  
  
Copyright (c) 2000, 2018, 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>   
6. 查看用戶信息

[html] view plain copy
mysql> select host,user,plugin,authentication_string from mysql.user;    
+-----------+------------------+-----------------------+------------------------------------------------------------------------+  
| host      | user             | plugin                | authentication_string                                                  |  
+-----------+------------------+-----------------------+------------------------------------------------------------------------+  
| %         | root             | caching_sha2_password | $A$005$^]RQB}j~t!      .#v)3.UogPRFu8VJA5/GKEbK5edEQlMT5sHw2n72zYJNlIbo3 |  
| localhost | mysql.infoschema | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE                              |  
| localhost | mysql.session    | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE                              |  
| localhost | mysql.sys        | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE                              |  
| localhost | root             | caching_sha2_password | $A$005$Y6&q!59^Fmh)@-6TG58J3F5+3I/HI9L|JCadNG+-+d6W+1D_UFW+7MRD7F3 |  
+-----------+------------------+-----------------------+------------------------------------------------------------------------+  
備注:host為 % 表示不限制ip   localhost表示本機使用    plugin非mysql_native_password 則需要修改密碼

navicat鏈接錯誤;我們繼續往下看;

 

 

mysql> ALTER user 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';  
Query OK, 0 rows affected (0.01 sec)  
mysql>   
mysql> FLUSH PRIVILEGES;  
Query OK, 0 rows affected (0.01 sec)  
  
mysql>   
7..連接數據庫的

 

 

 


連接成功了。
---------------------
作者:於英亮
來源:CSDN
原文:https://blog.csdn.net/weixin_42242494/article/details/80630267
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!


免責聲明!

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



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