外部无法连接docker下mysql

docker安装mysql后,本地navicat连接报错client does not support authentication

解决办法:
1. docker ps -a 查找到容器id
2. docker exec -it id /bin/bash 进入mysql容器 
3.mysql -u root -p root登陆mysql

4.alter user 'root'@'%' identified with mysql_native_password by '123456';

可能遇到问题:

Access denied for user 'root'@'localhost' (using password: YES)

解决办法:

update user set authentication_string = 'root' where user = 'root' and host = '%';
update user set authentication_string = 'root' where user = 'root' and host = 'localhost';

或者重新创建一个容器

原文地址:https://www.cnblogs.com/zhangmyname/p/12097327.html