help request: docker-compose启动mysql登陆不上
FunkyGod opened this issue · 5 comments
FunkyGod commented
Description
version: '3'
services:
mysql:
image: mysql:5.7.21
privileged: true
restart: always
container_name: apinto_mysql
hostname: apinto_mysql
ports:
- "33306:3306"
environment:
- MYSQL_ROOT_PASSWORD=123456
- MYSQL_DATABASE=apinto
volumes:
- /var/lib/apinto/mysql:/var/lib/mysql
networks:
- apinto
apinto-dashboard:
image: eolinker/apinto-dashboard
container_name: apinto-dashboard
privileged: true
restart: always
networks:
- apinto
ports:
- "18080:8080"
depends_on:
- mysql
- redis_cluster
environment:
- MYSQL_USER_NAME=root
- MYSQL_PWD=123456
- MYSQL_IP=apinto_mysql
- MYSQL_PORT=3306 #mysql端口
- MYSQL_DB="apinto"
- ERROR_DIR=/apinto-dashboard/work/logs # 日志放置目录
- ERROR_FILE_NAME=error.log # 错误日志文件名
- ERROR_LOG_LEVEL=info # 错误日志等级,可选:panic,fatal,error,warning,info,debug,trace 不填或者非法则为info
- ERROR_EXPIRE=7d # 错误日志过期时间,默认单位为天,d|天,h|小时, 不合法配置默认为7d
- ERROR_PERIOD=day # 错误日志切割周期,仅支持day、hour
- REDIS_ADDR=172.100.0.1:7201,172.100.0.1:7202,172.100.0.1:7203,172.100.0.1:7204,172.100.0.1:7205,172.100.0.1:7206 #Redis集群地址 多个用,隔开
- REDIS_PWD=123456 # Redis密码
volumes:
- /var/log/apinto/apinto-dashboard/work:/apinto-dashboard/work #挂载log到主机目录
redis_cluster:
container_name: redis_cluster
image: eolinker/cluster-redis:6.2.7
hostname: redis_cluster
privileged: true
restart: always
environment:
- REDIS_PWD=123456
- PORT=7201
- HOST=55.235.31.218
volumes:
- /var/lib/apinto/redis-cluster/data:/usr/local/cluster_redis/data
network_mode: host
networks:
apinto:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.100.0.0/24
Environment
- APINTO Dashboard version (run
apinto dashboard version
): - Operating system (run
uname -a
):
Dot-Liu commented
查一下mysql数据库容器初始化情况,如果mysql数据库正常,那就重启apinto-dashboard容器
docker restart apinto-dashboard
FunkyGod commented
Dot-Liu commented
看起来是数据库挂载失败引起的,初始密码也设置失败
Dot-Liu commented
请问问题解决了吗?
liudonghua123 commented
我自己也在写一个 docker-compose , mysql连接不上是因为默认root只允许localhost来连接,可以单独先启动mysql,然后exec进入mysql容器里面执行。
注意这里有一个巨坑,mysql 5.7 运行超级慢, mysql 8 不存在此问题,需要设置 ulimit 重启 docker,可参考
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
flush privileges;