1: 拉取mysql
docker pull mysql:8.0.28
2: 启动mysql
docker run --name mysql -d --restart=always -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 -e TZ=Asia/Shanghai mysql:8.0.28
3:进入mysql容器
docker exec -it mysql /bin/bash
4: 登录mysql
mysql -uroot -p
5:设置权限(为root分配权限,以便可以远程连接)
grant all PRIVILEGES on *.* to root@'%' WITH GRANT OPTION;
ALTER user 'root'@'%' IDENTIFIED BY 'abc#-' PASSWORD EXPIRE NEVER;
ALTER user 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'abc#-';
6:刷新配置
FLUSH PRIVILEGES;
7:修改mysql时区
set time_zone='+8:00';
set global time_zone='+8:00';
FLUSH PRIVILEGES;
8:登录mysql
mysql -uroot -pabc#- -h127.0.0.1 -P 3306 -D mysql
Docker 部署 mysql8(修改密码、修改时区)
于 2022-01-11 11:38:47 首次发布