title: Directus in docker cannot connect to mysql database in docker
body: <p>I have the following docker compose file. MySQL and phpmyadmin is working but directus cannot be initialised because it cannot connect to database.</p>
  <pre><code>version : '3'
  
  services:
    db:
      image: mysql:8
      container_name: dev_mysql
    environment:
      MYSQL_USER: directus
      MYSQL_PASSWORD: pa55word
      MYSQL_ROOT_PASSWORD: pa55word
      MYSQL_DATABASE: directus
    volumes:
      - ./db_data:/var/lib/mysql
    ports:
      - 9000:3306
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: dev_pma
    links:
      - db
    depends_on:
      - db
    environment:
      PMA_HOST: db
      PMA_PORT: 3306
      MYSQL_ROOT_PASSWORD: pa55word
    restart: always
    ports:
      - 8080:80
  directus:
    container_name: directus
    image: directus/directus:v9.0.0-rc.59
    ports:
      - 8055:8055
    links:
      - db
    depends_on:
      - db
    environment:
      KEY: '255d861b-5ea1-5996-9aa3-922530ec40b1'
      SECRET: '6116487b-cda1-52c2-b5b5-c8022c45e263'
  
      DB_CLIENT: 'mysql'
      DB_HOST: 'db'
      DB_PORT: '3306'
      DB_DATABASE: 'directus'
      DB_USER: 'directus'
      DB_PASSWORD: 'pa55word'
  
      ADMIN_EMAIL: 'admin@directus.com'
      ADMIN_PASSWORD: 'pa55word'
  </code></pre>
  <p>The docker compose log message I got is</p>
  <p>Starting dev_mysql ... done</p>
  <p>Starting dev_pma    ... done</p>
  <p>Recreating directus ... done</p>
  <p>Attaching to dev_mysql, dev_pma, directus</p>
  <p>dev_mysql     | 2021-04-17 08:39:14+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.</p>
  <p>dev_mysql     | 2021-04-17 08:39:14+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'</p>
  <p>dev_pma       | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.21.0.3. Set the 'ServerName' directive globally to suppress this message</p>
  <p>dev_pma       | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.21.0.3. Set the 'ServerName' directive globally to suppress this message</p>
  <p>dev_pma       | [Sat Apr 17 08:39:15.199501 2021] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.4.16 configured -- resuming normal operations</p>
  <p>dev_pma       | [Sat Apr 17 08:39:15.199574 2021] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'</p>
  <p>dev_mysql     | 2021-04-17 08:39:14+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.</p>
  <p>dev_mysql     | 2021-04-17T08:39:15.116541Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.23) starting as process 1</p>
  <p>dev_mysql     | 2021-04-17T08:39:15.122954Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive</p>
  <p>dev_mysql     | 2021-04-17T08:39:15.138364Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.</p>
  <p>directus      | 08:39:15 ✨ Initializing bootstrap...</p>
  <p>dev_mysql     | 2021-04-17T08:39:16.230177Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.</p>
  <p>dev_mysql     | 2021-04-17T08:39:16.390962Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock</p>
  <p>dev_mysql     | 2021-04-17T08:39:16.419710Z 0 [System] [MY-010229] [Server] Starting XA crash recovery...</p>
  <p>dev_mysql     | 2021-04-17T08:39:16.426595Z 0 [System] [MY-010232] [Server] XA crash recovery finished.</p>
  <p>dev_mysql     | 2021-04-17T08:39:16.527057Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.</p>
  <p>dev_mysql     | 2021-04-17T08:39:16.528010Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.</p>
  <p>dev_mysql     | 2021-04-17T08:39:16.539042Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.</p>
  <p>dev_mysql     | 2021-04-17T08:39:16.586905Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.23'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.</p>
  <p>directus      | 08:39:40 � Can't connect to the database</p>
  <p>directus exited with code 1</p>
  <p>Can anyone one please help to have a look? Thank you.</p>