Docker 安装 MySQL
sudo docker run -p 3306:3306 --name mysql \
-v /data/mysql/conf:/etc/mysql \
-v /data/mysql/logs:/var/log/mysql \
-v /data/mysql/data:/var/lib/mysql \
-v /data/mysql/mysql-files:/var/lib/mysql-files \
-e MYSQL_ROOT_PASSWORD=123456 \
--restart always \
-d mysql
// 已启动的执行以下命令开启自动重启服务
docker update --restart=always mysql
进入容器添加账号 & 设置权限
sudo docker exec -it mysql bash
# in bash
mysql
# in mysql bash
CREATE USER 'master'@'%' IDENTIFIED with mysql_native_password BY '123456';
GRANT ALL PRIVILEGES on *.* to 'master'@'%' with GRANT OPTION;