typecho / typecho/typecho

docker-compose环境,docker重启后网站数据库连接出错

Open
#879 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
12.4k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

报错信息:

SQLSTATE[HY000] [1045] Access denied for user 'mysql'@'172.18.0.3' (using password: YES)
Typecho_Db_Adapter_Exception: SQLSTATE[HY000] [1045] Access denied for user 'mysql'@'172.18.0.3' (using password: YES) in /app/var/Typecho/Db/Adapter/Pdo.php:60
Stack trace:
#0 /app/var/Typecho/Db.php(199): Typecho_Db_Adapter_Pdo->connect(Object(Typecho_Config))
#1 /app/var/Typecho/Db.php(350): Typecho_Db->selectDb(1)
#2 /app/var/Typecho/Db.php(384): Typecho_Db->query(Object(Typecho_Db_Query), 1)
#3 /app/var/Widget/Options.php(358): Typecho_Db->fetchAll(Object(Typecho_Db_Query), Array)
#4 /app/var/Typecho/Widget.php(221): Widget_Options->execute()
#5 /app/var/Widget/Init.php(27): Typecho_Widget::widget('Widget_Options')
#6 /app/var/Typecho/Widget.php(221): Widget_Init->execute()
#7 /app/index.php(17): Typecho_Widget::widget('Widget_Init')
#8 {main}

docker-compose.yml:

version: '2'
services:
  nginx:
    image: nginx:1.13.9-alpine
    container_name: blog_nginx
    ports:
      - "80:80"
    restart: always
    volumes:
      - ./typecho:/app
      - ./typecho.conf:/etc/nginx/conf.d/default.conf
      - ./logs:/var/log/nginx
    links:
      - php-fpm
    depends_on:
      - php-fpm

  php-fpm:
    image: anguiao/php-fpm
   container_name: blog_fpm
    expose:
      - 9000
    volumes:
      - ./typecho:/app
    restart: always
    links:
      - mysql
    depends_on:
      - mysql
  mysql:
    image: mysql:5.7
    container_name: blog_db
    expose:
      - 3306
    volumes:
      - ./mysql:/var/lib/mysql/:rw
      - ./logs:/var/logs/mysql
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=123456
      - MYSQL_DATABASE=typecho
      - MYSQL_USER=typecho
      - MYSQL_PASSWORD=123456
  • 数据库版本:5.7
  • PHP 版本:7.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with docker-compose.yml and the reported connection path in var/Typecho/Db/Adapter/Pdo.php, then reproduce the failure after restarting Docker. Check whether the configured MySQL credentials and persisted database state still permit the application connection; done means the site starts and connects to its database successfully after a restart.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker-compose, mysql, php
Domain
backend, databases, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.