【问题标题】:SQLSTATE[HY000] [2006] MySQL server has gone away in dockerSQLSTATE[HY000] [2006] MySQL 服务器已在 docker 中消失
【发布时间】:2020-05-26 08:33:13
【问题描述】:

连接docker数据库时不工作,docker在主机上,可能是localhost的问题,我不知道到底是什么问题,所以我在下面附上mysql容器的状态,我再说一遍,也许原因正是我将docker部署在服务器上而不是本地主机上,但我不确定这是否应该有问题

staging-mariadb

staging-mariadb        | 2020-05-26 08:17:50+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.13+maria~bionic started.
staging-mariadb        | 2020-05-26 08:17:50+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
staging-mariadb        | 2020-05-26 08:17:50+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.13+maria~bionic started.
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] mysqld (mysqld 10.4.13-MariaDB-1:10.4.13+maria~bionic) starting as process 1 ...
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] InnoDB: Using Linux native AIO
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] InnoDB: Uses event mutexes
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] InnoDB: Number of pools: 1
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] InnoDB: Using SSE2 crc32 instructions
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] InnoDB: Completed initialization of buffer pool
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] InnoDB: Creating shared tablespace for temporary tables
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] InnoDB: Waiting for purge to start
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] InnoDB: 10.4.13 started; log sequence number 60990; transaction id 21
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] Plugin 'FEEDBACK' is disabled.
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] Server socket created on IP: '::'.
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] InnoDB: Buffer pool(s) load completed at 200526  8:17:51
staging-mariadb        | 2020-05-26  8:17:51 0 [Warning] 'user' entry 'root@3995f63929b6' ignored in --skip-name-resolve mode.
staging-mariadb        | 2020-05-26  8:17:51 0 [Warning] 'user' entry '@3995f63929b6' ignored in --skip-name-resolve mode.
staging-mariadb        | 2020-05-26  8:17:51 0 [Warning] 'proxies_priv' entry '@% root@3995f63929b6' ignored in --skip-name-resolve mode.
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] Reading of all Master_info entries succeeded
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] Added new Master_info '' to hash table
staging-mariadb        | 2020-05-26  8:17:51 0 [Note] mysqld: ready for connections.
staging-mariadb        | Version: '10.4.13-MariaDB-1:10.4.13+maria~bionic'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
staging-mariadb        | 2020-05-26  8:21:54 8 [Warning] Aborted connection 8 to db: 'unconnected' user: 'unauthenticated' host: '192.168.144.3' (This connection closed normally without authentication)
staging-mariadb        | 2020-05-26  8:21:54 9 [Warning] Aborted connection 9 to db: 'unconnected' user: 'unauthenticated' host: '192.168.144.3' (This connection closed normally without authentication)

码头工人撰写

version: "3.7"

services:

  staging-nginx:
    container_name: staging-nginx
    build:
      context: project/docker
      dockerfile: staging/nginx/Dockerfile
    ports:
      - ${PROJECT_PORT}:80
    volumes:
      - ./project:/app
    depends_on:
      - staging-php-fpm
      - staging-php-cli

  staging-php-fpm:
    container_name: staging-php-fpm
    build:
      context: project/docker
      dockerfile: staging/php-fpm/Dockerfile
    environment:
      YII_DEBUG: ${YII_DEBUG}
      YII_ENV: ${YII_ENV}
      COOKIE_KEY: ${COOKIE_KEY}
      MYSQL_HOST: ${MYSQL_HOST}
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
      MYSQL_DATABASE_TABLE_PREFIX: ${MYSQL_DATABASE_TABLE_PREFIX}
      PROJECT_PORT: ${PROJECT_PORT}
      MYSQL_PORT: ${MYSQL_PORT}
      PHPMYADMIN_PORT: ${PHPMYADMIN_PORT}
      API_URL: ${API_URL}
      API_PATH: ${API_PATH}
      API_NAME: ${API_NAME}
      API_EXACT_VERSION: ${API_EXACT_VERSION}
      APP_ADMIN_NAME: ${APP_ADMIN_NAME}
      APP_ADMIN_EMAIL: ${APP_ADMIN_EMAIL}
      APP_ADMIN_PASSWORD: ${APP_ADMIN_PASSWORD}
    volumes:
      - ./project:/app
    depends_on:
      - staging-mariadb

  staging-php-cli:
    container_name: project-php-cli
    build:
      context: project/docker
      dockerfile: staging/php-cli/Dockerfile
    environment:
      YII_DEBUG: ${YII_DEBUG}
      YII_ENV: ${YII_ENV}
      COOKIE_KEY: ${COOKIE_KEY}
      MYSQL_HOST: ${MYSQL_HOST}
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
      MYSQL_DATABASE_TABLE_PREFIX: ${MYSQL_DATABASE_TABLE_PREFIX}
      PROJECT_PORT: ${PROJECT_PORT}
      MYSQL_PORT: ${MYSQL_PORT}
      PHPMYADMIN_PORT: ${PHPMYADMIN_PORT}
      API_URL: ${API_URL}
      API_PATH: ${API_PATH}
      API_NAME: ${API_NAME}
      API_EXACT_VERSION: ${API_EXACT_VERSION}
      APP_ADMIN_NAME: ${APP_ADMIN_NAME}
      APP_ADMIN_EMAIL: ${APP_ADMIN_EMAIL}
      APP_ADMIN_PASSWORD: ${APP_ADMIN_PASSWORD}
    volumes:
      - ./project:/app
      - composer:/root/.composer/cache
    depends_on:
      - staging-mariadb

  staging-mariadb:
    container_name: staging-mariadb
    build:
      context: project/docker
      dockerfile: staging/mariadb/Dockerfile
    environment:
      MYSQL_RANDOM_ROOT_PASSWORD: 1
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
    ports:
      - ${MYSQL_PORT}:3306
    volumes:
      - db:/var/lib/mysql

volumes:
  composer:
  db:

【问题讨论】:

标签: mysql docker server mariadb


【解决方案1】:

问题是我在 MySQL 恶魔工作之前杀死了它,因此整个数据库都崩溃了......

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-30
    • 2012-05-15
    相关资源
    最近更新 更多