官方镜像地址:
https://hub.docker.com/_/mysql?tab=tags&page=1&ordering=last_updated
运行
docker run \
--name mysql8 \
-p 3306:3306 \
-v /Users/wenbronk/Containers/Data/mysql/data:/var/lib/mysql \
-v /Users/wenbronk/Containers/Data/mysql/log:/var/log/mysql \
-v /Users/wenbronk/Containers/Data/mysql/my.cnf:/etc/mysql/my.cnf:rw \
-e MYSQL_ROOT_PASSWORD=password \
--restart=always \
-d mysql:8.0.16
如果遇到
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
则仅需在容器内
mysql -uroot -h 127.0.0.1 -p