-
执行命令装置 mysql
docker run -d --privileged=true \ --restart=always \ --name mysql \ -v /usr/local/mysql/data:/var/lib/mysql \ -v /usr/local/mysql/conf:/etc/mysql \ -v /usr/local/mysql/log:/var/log/mysql \ -p 8306:3306 \ -e TZ=Asia/Shanghai \ -e MYSQL_ROOT_PASSWORD=123456 \ mysql:5.6 \ --character-set-server=utf8mb4 \ --collation-server=utf8mb4_general_ci
装置 mysql5.7 会报错
-
进入 mysql 容器,登录 mysql
docker exec -it mysql bash mysql -u root -p 123456
-
批改 root 明码,并容许近程登录
set password for [email protected] = password('新密码'); set password for [email protected]'%' = password('新密码'); GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '新密码' WITH GRANT OPTION;
装置结束