docker 安装mysql8

拉取镜像并运行和配置映射路径

docker run -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -v /usr/local/mysql/data:/var/lib/mysql:rw -v /usr/local/mysql/mysql-files:/var/lib/mysql-files:rw -v /usr/local/mysql/log:/var/log/mysql:rw -v /usr/local/mysql/config:/etc/mysql:rw -v /etc/localtime:/etc/localtime:ro --name mysql --restart=always -d mysql:8.0.16

添加用户

CREATE USER 'test'@'%' IDENTIFIED WITH mysql_native_password BY 'lfptest';

授权

GRANT ALL ON . TO 'test'@'%' WITH GRANT OPTION;