1、进入mysql容器docker exec -it my_mysql /bin/bash
2、登陆mysql , 选择数据库mysql -u root -p
use mysql
3、mysql 8 设置允许远程用户访问update user set host = '%' where user = 'root' and host='localhost';
# 更新root - localhost 为 root - %
GRANT ALL ON *.* TO 'root'@'%';
# 设置允许远程用户访问
flush privileges;
# 刷新权限
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '密码';
#更新用户加密方式,mysql8默认的加密方式为caching_sha2_password 与mysql5的加密方式mysql_native_password 不同
3、Docker中可以增加参数 --default-authentication-plugin=mysql_native_password
4、K8s中可以增加参数 args: ["--default-authentication-plugin=mysql_native_password"]