拉取镜像mysql/mysql-server:5.7
启动
docker run --name mysql -v /data/mysql:/var/lib/mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql/mysql-server:5.7
切到mysql中使用命令行授权,允许远程访问
docker exec -it mysql bash
mysql
use mysql;
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;