docker-library / mysql

Docker Official Image packaging for MySQL Community Server
https://dev.mysql.com/
GNU General Public License v2.0
2.42k stars 2.18k forks source link

Container not working after building it #1054

Closed seikettune closed 1 month ago

seikettune commented 1 month ago

I'm using using mysql image with tag :latest. While building I get following errors (among many others but I assume that container fails to run correctly due either one or both of these errors?

  1. [ERROR] [Server] unknown variable 'default_authentication_plugin=mysql_native_password'.
  2. [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.

What gives? I'm totally lost here and I've tried everything I can imagine that could cause this.

Also note that my mysql container was functioning just fine a while ago.

Here's my docker-compose.yml:

version: "3.8"
services:

# -------------------- #
# container defintions #
# -------------------- #
  # PHP-FPM + workspace
  app:
    build:
      context: ./
      args:
        USER_ID: ${USERID:-1000}
        GROUP_ID: ${GROUPID:-1000}
      dockerfile: dockerfiles/application.dockerfile
    image: cornerstone
    networks:
      - cornerstone
    volumes:
      - ../:/var/www/html:delegated
      - npm_cache:/home/docker-apache/.npm:delegated
      - composer_cache:/home/docker-apache/.composer:delegated
      - bash_history:/commandhistory:delegated
    environment:
      APACHE_RUN_USER: "#${USERID:-1000}"
      APACHE_RUN_GROUP: "#${GROUPID:-1000}"
      WSLIP: ${WSLIP:-}
    restart: on-failure
    ports:
      - 8000:8000
      - 8001:8001
      - 9011:9011
    depends_on:
      - mysql
      - apache

  # Apache proxy, passes HTTP requests to application container
  apache:
    build:
      dockerfile: dockerfiles/apache.dockerfile
      context: ./
      args:
        USER_ID: ${USERID:-1000}
        GROUP_ID: ${GROUPID:-1000}
    image: cornerstone_apache
    networks:
      - cornerstone
    volumes:
      - ../:/var/www/html:delegated
    restart: on-failure
    ports:
      - 80:80
      - 443:443
    environment:
      APACHE_RUN_USER: "#${USERID:-1000}"
      APACHE_RUN_GROUP: "#${GROUPID:-1000}"

  # Database container
  mysql:
    image: mysql:latest
    networks:
      - cornerstone
    volumes:
      - database:/var/lib/mysql:delegated
      - ../web/seed-data/database:/docker-entrypoint-initdb.d
    restart: on-failure
    environment:
      MYSQL_ROOT_PASSWORD: "securepasswordxd"
      MYSQL_DATABASE: "docker"
      MYSQL_PASSWORD: "docker"
      MYSQL_USER: "docker"
    expose:
      - 3306
    command: mysqld --default_authentication_plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_swedish_ci

  # Redis, in case you want to test persistent object caching
  redis:
    image: redis
    ports:
      - 6379:6379

  # Sometimes its usefult to have some kind of GUI into database, so Adminder
  adminer:
    image: adminer:latest
    networks:
      - cornerstone
    restart: on-failure
    depends_on:
      - mysql
    ports:
      - 8080:8080
    environment:
      ADMINER_DEFAULT_DB_DRIVER: mysql
      ADMINER_DEFAULT_DB_HOST: mysql
      ADMINER_DEFAULT_DB_NAME: ${MYSQL_DATABASE}
      ADMINER_DESIGN: nette
      ADMINER_PLUGINS: tables-filter tinymce

# ------------------ #
# volume definitions #
# ------------------ #
volumes:
  database:
  npm_cache:
    external: true
  composer_cache:
    external: true
  bash_history:
    external: true

# ------------------- #
# network definitions #
# ------------------- #
networks:
  cornerstone:
    driver: bridge
tianon commented 1 month ago

Sounds like you're getting bitten by the recent update to the new 8.4 upstream release. I would suggest pinning to a more specific version of MySQL (and checking the MySQL 8.4 release notes for clues to why your updated deployment is failing).

seikettune commented 1 month ago

@tianon yup that was indeed the case.

I updated the mysqld command to match the latest mysql specs.

How it was: command: mysqld --default_authentication_plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_swedish_ci

How it is now: command: mysqld --mysql-native-password=ON --authentication_policy=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_swedish_ci

Mysql-native-password=ON to meet the needs of wordpress.

tianon commented 1 month ago

With the caveat/warning that they do intend to remove that functionality completely in the future (so eventually the square wheel will roll again and this will come back out from under the rug :see_no_evil:).