Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploying mrdoc-nginx:0.7.6-with-mysql using docker-compose throws db access denied #136

Open
crazydogen opened this issue Mar 8, 2022 · 1 comment

Comments

@crazydogen
Copy link

Using docker-compose to deploy mrdoc-nginx:0.7.6-with-mysql.

ERROR:

File "/usr/local/lib/python3.7/site-packages/MySQLdb/connections.py", line 185, in init
super().init(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (1045, "Access denied for user '7d6a4'@'172.31.0.3' (using password: YES)")
django.db.utils.OperationalError: (1045, "Access denied for user '7d6a4'@'172.31.0.3' (using password: YES)")

docker-compose.yml

services:
  mrdoc:
    image: jonnyan404/mrdoc-nginx:0.7.6-with-mysql
    container_name: mrdoc-with-mysql
    restart: always
    volumes:
      - /opt/home/mrdoc/config:/app/MrDoc/config  # 请注意修改 /path/to/you/dir 为您要存储mrdoc数据的绝对路径.
      - /opt/home/mrdoc/media:/app/MrDoc/media    # 同上
    environment:
      - TZ=Asia/Shanghai
      ###### 以下注释项为可选变量
      - LISTEN_PORT=10086   # 自定义端口
      # - CREATE_USER=1       # 0 不创建管理员用户, 1 创建管理员用户,默认是1
      # - USER=xx     # 自定义管理员用户名
      # - MM=xx                # 自定义管理员密码
      ###### 如果默认用户密码,以及变量添加用户密码无法登录,请参考:https://www.mrdoc.fun/project-1/doc-242/
    ports:
      - "7890:10086"
    depends_on:
      - mysql
  mysql:
    image: mysql:5.7
    container_name: mysql-with-mrdoc    # 这里名字请不要修改,否则数据库会连接失败.
    restart: always
    volumes:
      - /opt/home/mrdoc/mysql:/var/lib/mysql # 请注意修改 /path/to/you/dir 为您要存储mysql数据的目录绝对路径.
    environment:
      - TZ=Asia/Shanghai
      - MYSQL_ROOT_PASSWORD=Jonnyan404!
      - MYSQL_DATABASE=mrdoc
      - MYSQL_USER=jonnyan404
      - MYSQL_PASSWORD=www.mrdoc.fun
    expose:
      - "3306"
    ports:
      - "63306:3306"  # 如果不需要外部连接mysql,可注释此行+上一行.
    command:
      - "--character-set-server=utf8mb4"
      - "--collation-server=utf8mb4_unicode_ci"
# Volumes for persisting data, see https://docs.docker.com/engine/admin/volumes/volumes/
#volumes:
#  mrdoc-data:
#    driver: local
#  mysql-data:
#    driver: local

Solution?

https://stackoverflow.com/questions/17425523/python-mysql-operationalerror-1045-access-denied-for-user-rootlocalhost

@Jonnyan404
Copy link
Contributor

由于mysql初始化过慢,
需要等待mysql初始化后(根据机器性能,大概1-3分钟左右),
再次重启mrdoc.


请确定是否按照上述步骤操作后的报错?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants