下拉镜像使用镜像创建docker容器进入mysql修改mysql访问权限授权刷新权限修改root密码刷新权限 下拉镜像
docker pull mysql/mysql-server:latest
使用镜像创建docker容器docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql/mysql-server
进入mysql修改mysql访问权限# 进入mysql宿主机docker exec -it mysql bash# 进入mysql命令行mysql -u root -p 123456
授权CREATE USER 'root'@'%' IDENTIFIED BY 'root';GRANT ALL ON *.* TO 'root'@'%';
刷新权限flush privileges;
修改root密码ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
刷新权限flush privileges;