docker容器中出现Access denied for user 'root'@'172.17.0.2' (using password: YES)解决
2020-05-07 04:21
3147 查看
首先有必要说明下,172.17.0.2 是我访问mysql容器的应用容器IP
环境说明
- 宿主机,ubuntu
- 容器1: docker_for_api ,提供应用的API服务。
- 容器2: docker_for_web,提供应用的后台管理页面。
- 容器3: docker_for_mysql ,数据库容器。
问题复现
程序中突然就出现了
Access denied for user ‘root’@‘172.17.0.2’ (using password: YES)
的错误,因为,我的API中连接数据库 是 这样配置的。
一直以为是docker_for_api 这个容器有缓存啥的问题。搞了好久。后来才返现就是docker_for_mysql这个容器的问题。(权限问题,后来网上找的解决办法,然后结合我自己的服务部署的实际情况。)
好,进入正题,解决方案
假设你现在已经在你的宿主机了
进入docker_for_mysql 这个容器
docker exec -it mymysql bash
用命令进入mysql 中
(我想把下面的语句称之为降权,不知道说不说的过去。)
grant all privileges on *.* to root@'%' identified by '123456' with grant option;
不出意外的话会有个 “Query Ok"
下面刷新下权限
flush privileges;
结果可能与你们有点出入,因为我是为了截图,都是第二次输入的命令。总之有OK字样是没问题的,最后exit;
exit;
最后 你再用工具连接测试 发现一切正常了。
没成功的话,继续去找解决方案把。
No Big Deal 原创文章 11获赞 2访问量 2051 关注 私信相关文章推荐
- 打开Navicat Premium连接mysql出现1045-Access denied for user 'root'@ 'localhost'(using password:YES)错误解决方法
- 使用MySQL API时出现如下问题的解决方法:Access denied for user 'root'@'localhost' (using password: YES)
- Linux下连接Mysql出现:Access denied for user 'root'@'localhost' (using password:YES)的解决方法
- 当Navicat for Mysql出现 1045 -Access denied for user'root'@'ipAddress'(using password :yes)解决方法
- 解决用远程连接mysql数据库出现1045 access denied for user 'root'@'localhost' using password yes
- MySQL登录时出现 Access denied for user 'root'@'xxx.xxx.xxx.xxx' (using password: YES) 的原因及解决办法
- 常出现的Access denied for user 'root'@'localhost' (using password: YES)及其相关问题解决
- mysql 出现 1045 access denied for user 'root'@'localhost' using password yes 解决办法
- 连接mysql数据库出现错误:1045-Access denied for user 'root'@'localhost' (using password:YES) 解决方法
- 解决用Mysql 使用navicate远程连接数据库出现1045 access denied for user 'root'@'localhost' using password yes
- MySql 出现ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES).问题解决方案
- MySQL登录时出现 Access denied for user 'root'@'xxx.xxx.xxx.xxx' (using password: YES) 的原因及解决办法
- 登陆MySQL出现error:‘Access denied for user 'root'@localhost (using password :YES)'解决方法
- 解决Navicat连接的时候出现了1045 -Access denied for user'root'@'ip'(using password :yes)--mysql
- 使用dbcp出现 Access denied for user 'root'@'localhost' (using password:YES) 的解决办法
- 解决Navicat连接的时候出现了1045 -Access denied for user'root'@'192.168.37.2'(using password :yes)
- windows下出现Access denied for user 'root '@'localhost' (using password: YES)的解决方法
- MySql连接出现Access denied for user 'root'@'localhost' (using password: YES)解决方法(附其它关联安装过程中的问题)
- 如何解决PHP连接MySQL时出现的Access denied for user 'root' @ 'localhost'(using password :YES)
- 连接mysql出现Access denied for user ‘root’@’localhost’ (using password:YES)问题解决办法