Search code examples
mysqldocker-compose

MySQL inside docker compose on github codespace 16gb ram is running into issues


I tried to run MySQL independently. It is one of many services for a open source project I am trying to get running. I found out what part is causing issues, it is "--default-authentication-plugin=mysql_native_password". So this docker-compose.yml does not work:

  db:
    image: mysql:8
    restart: always
    command: --default-authentication-plugin=mysql_native_password --sql_mode="" --skip-name-resolve --tls-version=""
    environment:
      MYSQL_ROOT_PASSWORD: ${MASTER_MYSQL_ROOT_PASSWORD}
      MYSQL_DATABASE: ${MASTER_MYSQL_DATABASE}
      MYSQL_USER: ${MASTER_MYSQL_USER}
      MYSQL_PASSWORD: ${MASTER_MYSQL_PASSWORD}

It gives me this error:

    /workspaces/cron-job.org (master) $ docker compose up
    WARN[0000] Found orphan containers ([cron-joborg-mysql-1]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. 
    [+] Running 2/2
     ✔ Network cron-joborg_default  Created                                                                                                                                                                                          0.1s 
     ✔ Container cron-joborg-db-1   Created                                                                                                                                                                                          0.2s 
    Attaching to db-1
    db-1  | 2024-06-06 03:57:28+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.4.0-1.el9 started.
    db-1  | 2024-06-06 03:57:28+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
    db-1  | 2024-06-06 03:57:28+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.4.0-1.el9 started.
    db-1  | 2024-06-06 03:57:28+00:00 [Note] [Entrypoint]: Initializing database files
    db-1  | 2024-06-06T03:57:28.550651Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
    db-1  | 2024-06-06T03:57:28.551801Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.4.0) initializing of server in progress as process 80
    db-1  | 2024-06-06T03:57:28.572331Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
    db-1  | 2024-06-06T03:57:29.694256Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
    db-1  | 2024-06-06T03:57:35.532272Z 0 [Warning] [MY-013595] [Server] Failed to initialize TLS for channel: mysql_main. See below for the description of exact issue.
    db-1  | 2024-06-06T03:57:35.532301Z 0 [Warning] [MY-010069] [Server] Failed to set up SSL because of the following SSL library error: TLS version is invalid
    db-1  | 2024-06-06T03:57:35.688029Z 0 [ERROR] [MY-000067] [Server] unknown variable 'default-authentication-plugin=mysql_native_password'.
    db-1  | 2024-06-06T03:57:35.688442Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
    db-1  | 2024-06-06T03:57:35.688460Z 0 [ERROR] [MY-010119] [Server] Aborting
    db-1  | 2024-06-06T03:57:37.256251Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.
    db-1 exited with code 0

I tried looking up the errors one by one but can't fix it. Spent 1.5 hours on it. I tried implementing this answer: https://stackoverflow.com/a/50130973/16345931 But with the CONTAINER_ID substiuted in "docker exec -it CONTAINER_ID bash", I see the "password:" prompt until I type the second character, then it goes back to command mode. I found the CONTAINER_ID using docker ps ofc.

This config works just fine:

      db:
        image: mysql:8
        restart: always
        command: --sql_mode="" --skip-name-resolve --tls-version=""
        environment:
          MYSQL_ROOT_PASSWORD: ${MASTER_MYSQL_ROOT_PASSWORD}
          MYSQL_DATABASE: ${MASTER_MYSQL_DATABASE}
          MYSQL_USER: ${MASTER_MYSQL_USER}
          MYSQL_PASSWORD: ${MASTER_MYSQL_PASSWORD}

I just found this but haven't tried it: "As of MySQL 8.0, caching_sha2_password is both the preferred and the default authentication plugin." - MySQL Server 8.0.12 - An authentication plugin must be specified for new users

Is that correct?

Could anyone try running the docker compose file on a github codespace? And is "--default-authentication-plugin=mysql_native_password" even necessary for MySQL to work? Would any help, I've sunk too much time into this.


Solution

  • As mysql manual on default-authentication-plugin says:

    Because of this diminished role, default_authentication_plugin is deprecated as of MySQL 8.0.27 and subject to removal in a future MySQL version.

    This server variable has been remived from v8.4, so it is not needed.

    In the future, please ask such questions on the DBA sister site of SO as it has nothing to do with programming or sw development, only with mysql internal operations!