1.拉取mysql镜像
docker pull mysql:latest
2.启动容器
docker run --restart=always -d -v /root/mysql/conf/my.cnf:/etc/mysql/my.cnf -p 3306:3306 --name webpy-mysql -e MYSQL_ROOT_PASSWORD=Warp1234 mysql
3.进入容器
docker exec -it webpy-mysql bash
4.mysql初始化
mysql -u root -p
#重置root密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Warp1234';
#添加远程登录用户
CREATE USER 'xinchen.luan'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
GRANT ALL PRIVILEGES ON *.* TO 'xinchen.luan'@'%';
* Plugin报错解决
select host,user,plugin from user;
alter user 'root'@'%' identified with mysql_native_password by 'Warp234';