mysql sqlyog提示2058错误或者用Navicat连接本机Docker的Mysql 和一些问题的解决方案...

本文详细介绍了如何使用Docker快速部署MySQL数据库,包括下载Docker镜像、设置root账号密码、映射端口、查看运行容器、进入容器内部以及通过Navicat连接数据库等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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..连接数据库的

 

 

 


连接成功了。
---------------------
作者:于英亮
来源:优快云
原文:https://blog.youkuaiyun.com/weixin_42242494/article/details/80630267
版权声明:本文为博主原创文章,转载请附上博文链接!

转载于:https://www.cnblogs.com/weizhxa/p/10114158.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值