1.拉取mysql
docker pull mysql:latest
2.创建mysql容器
docker run -d -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=123456 mysql
3.登陆mysql
docker exec -it mysql /bin/bash
mysql -u root -p
4.开启root远程访问
use mysql;
ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘123456’;
flush privileges;
select host,user,plugin,authentication_string from mysql.user;
5.重启mysql容器
docker restart mysql