title: Laravel Sail Database & User not created
body: <p>I just set up a laravel project with laravel sail and for some reason during build process it doesn't create the given database and user. I am quite confused as to why because I feel like I've configured everything right.</p>
  <p>When executing <code>./vendor/bin/sail artisan migrate</code> I get following error which indicates that the user given in my .env either doesn't exist or has wrong credentials:</p>
  <pre><code> Illuminate\Database\QueryException 
  
    SQLSTATE[HY000] [1045] Access denied for user 'Laravel'@'192.168.0.5' (using password: YES) 
  (SQL: select * from information_schema.tables where table_schema = shop and table_name = migrations and table_type = 'BASE TABLE')
  </code></pre>
  <p>Checking my Database as root user showed me that it indeed hasn't got the <code>Laravel</code> user configured:</p>
  <pre><code>mysql&gt; SELECT user, host FROM mysql.user;
  +------------------+-----------+
  | user             | host      |
  +------------------+-----------+
  | root             | %         |
  | mysql.infoschema | localhost |
  | mysql.session    | localhost |
  | mysql.sys        | localhost |
  | root             | localhost |
  +------------------+-----------+
  5 rows in set (0.00 sec)
  </code></pre>
  <p>After further inspection I found out that not even the database was created:</p>
  <pre><code>mysql&gt; SHOW DATABASES;
  +--------------------+
  | Database           |
  +--------------------+
  | information_schema |
  | mysql              |
  | performance_schema |
  | sys                |
  +--------------------+
  4 rows in set (0.01 sec)
  </code></pre>
  <p>This is my .env:</p>
  <pre><code>PP_NAME=Laravel
  APP_ENV=local
  APP_KEY=base64:nzYXOsqDlSiRuBsaDVcrUiKfQhekjhhpJlq3VKSo0M8=
  APP_DEBUG=true
  APP_URL=http://ak-wear.test
  
  LOG_CHANNEL=stack
  LOG_LEVEL=debug
  
  DB_CONNECTION=mysql
  DB_HOST=mysql
  DB_PORT=3306
  DB_DATABASE=shop
  DB_ROOT_PASSWORD=
  DB_USERNAME=Laravel
  DB_PASSWORD=ak123456
  ...
  </code></pre>
  <p>This is my docker-compose.yml:</p>
  <pre><code># For more information: https://laravel.com/docs/sail
  version: '3'
  services:
      laravel.test:
          build:
              context: ./vendor/laravel/sail/runtimes/8.0
              dockerfile: Dockerfile
              args:
                  WWWGROUP: '${WWWGROUP}'
          image: sail-8.0/app
          ports:
              - '${APP_PORT:-80}:80'
          environment:
              WWWUSER: '${WWWUSER}'
              LARAVEL_SAIL: 1
          volumes:
              - '.:/var/www/html'
          networks:
              - sail
          depends_on:
              - mysql
              # - pgsql
              - redis
              # - selenium
      # selenium:
      #     image: 'selenium/standalone-chrome'
      #     volumes:
      #         - '/dev/shm:/dev/shm'
      #     networks:
      #         - sail
      mysql:
          image: 'mysql:8.0'
          ports:
              - '${FORWARD_DB_PORT:-3306}:3306'
          environment:
              MYSQL_ROOT_PASSWORD: '${DB_ROOT_PASSWORD}'
              MYSQL_DATABASE: '${DB_DATABASE}'
              MYSQL_USER: '${DB_USERNAME}'
              MYSQL_PASSWORD: '${DB_PASSWORD}'
              MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
          volumes:
              - 'sailmysql:/var/lib/mysql'
          networks:
              - sail
          healthcheck:
            test: [&quot;CMD&quot;, &quot;mysqladmin&quot;, &quot;ping&quot;]
  #    pgsql:
  #        image: postgres:13
  #        ports:
  #            - '${FORWARD_DB_PORT:-5432}:5432'
  #        environment:
  #            PGPASSWORD: '${DB_PASSWORD:-secret}'
  #            POSTGRES_DB: '${DB_DATABASE}'
  #            POSTGRES_USER: '${DB_USERNAME}'
  #            POSTGRES_PASSWORD: '${DB_PASSWORD:-secret}'
  #        volumes:
  #            - 'sailpostgresql:/var/lib/postgresql/data'
  #        networks:
  #            - sail
  #        healthcheck:
  #          test: [&quot;CMD&quot;, &quot;pg_isready&quot;, &quot;-q&quot;, &quot;-d&quot;, &quot;${DB_DATABASE}&quot;, &quot;-U&quot;, &quot;${DB_USERNAME}&quot;]
      redis:
          image: 'redis:alpine'
          ports:
              - '${FORWARD_REDIS_PORT:-6379}:6379'
          volumes:
              - 'sailredis:/data'
          networks:
              - sail
          healthcheck:
            test: [&quot;CMD&quot;, &quot;redis-cli&quot;, &quot;ping&quot;]
      # memcached:
      #     image: 'memcached:alpine'
      #     ports:
      #         - '11211:11211'
      #     networks:
      #         - sail
      mailhog:
          image: 'mailhog/mailhog:latest'
          ports:
              - '${FORWARD_MAILHOG_PORT:-1025}:1025'
              - '${FORWARD_MAILHOG_DASHBOARD_PORT:-8025}:8025'
          networks:
              - sail
  networks:
      sail:
          driver: bridge
  volumes:
      sailmysql:
          driver: local
  #    sailpostgresql:
  #        driver: local
      sailredis:
          driver: local
  </code></pre>
  <p>Of course I could create the database and user myself but since Sail/Docker-Compose ship with these options I want to make them work out of the box when setting up my project with Sail. Does anyone have an idea why the database and user are not created?</p>