docker 中下载 mysql
docker 安装可以参考:https://www.cnblogs.com/dehigher/p/10091479.html
docker pull mysql
#启动
docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=abc123456 -v /etc/mysql.d:/etc/mysql/conf.d --name mysql mysql
#进入容器
docker exec -it mysql bash
#登录mysql
mysql -u root -p
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘abc123456’;
#添加远程登录用户
CREATE USER ‘%’@’%’ IDENTIFIED WITH mysql_native_password BY ‘abc123456’;
修改
ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘abc123456’;
刷新生效
FLUSH PRIVILEGES;
也可以参考下面:
https://www.cnblogs.com/zhi-leaf/p/10561766.html
异常处理
Navicat for MySQL 连接 Docker中运行的Mysql出现1251- Client does not support authentication protocol 错误