title: Docker mysql connection fail with laravel
body: <p>So I’m having troubles getting my Laravel app to connect to my MySQL container. With the following docker-compose I get the error:</p>
  
  <blockquote>
    <p>Connection refused (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrations)</p>
  </blockquote>
  
  <pre><code>database:
    image: mysql:5.7
      volumes:
        - dbdata:/var/lib/mysql
       environment:
        - "MYSQL_ROOT_PASSWORD=secret"
        - "MYSQL_DATABASE=homestead"
        - "MYSQL_USER=root"
        - "MYSQL_PASS=secret"
      ports:
        - "33061:3306"
  </code></pre>
  
  <p>If I change my image to mysql I get the error:</p>
  
  <blockquote>
    <p>The server requested authentication method unknown to the client (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrations)</p>
    
    <p>The server requested authentication method unknown to the client [caching_sha2_password]</p>
  </blockquote>
  
  <p>My laravel .env looks like this:</p>
  
  <pre><code>DB_CONNECTION=mysql
  DB_HOST=127.0.0.1
  DB_PORT=3306
  DB_DATABASE=homestead
  DB_USERNAME=root
  DB_PASSWORD=secret
  </code></pre>
  
  <p>I tried DB_HOST=database as well.</p>
  
  <p>Any help would be great. Thanks!</p>
  
  <p>OS: OSX</p>