赞
踩
version: "3" networks: gitea: external: false services: server: image: gitea/gitea:1.15.6 container_name: gitea environment: - USER_UID=1000 - USER_GID=1000 - GITEA__database__DB_TYPE=mysql - GITEA__database__HOST=db:3306 - GITEA__database__NAME=gitea - GITEA__database__USER=gitea - GITEA__database__PASSWD=gitea restart: always networks: - gitea volumes: - ./gitea:/data - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro ports: - "3000:3000" - "222:222" depends_on: - db db: image: mysql:8 restart: always environment: - MYSQL_ROOT_PASSWORD=gitea - MYSQL_USER=gitea - MYSQL_PASSWORD=gitea - MYSQL_DATABASE=gitea networks: - gitea volumes: - ./mysql:/var/lib/mysql
如果直接使用设置的root账户连接的话,问题很多,索性没有时间的情况下,可以直接新建一个新的用户,新建的用户可以连接得上
docker run -itd --name mysql8 -p 3308:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql
#进入容器
docker exec -it [CONTAINER ID] bash
#登录mysql
mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY '密码';
#添加远程登录用户
CREATE USER '用户名'@'%' IDENTIFIED WITH mysql_native_password BY '密码';
GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%';
创建一个新用户就能直接操作了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。