Docker Community Forums

Share and learn in the Docker community.

MySQL Connection


(Munch1431) #1

Hello,

So I’m having troubles getting my Laravel app to connect to my MySQL container. With the following docker-compose I get the error:

Connection refused (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrations)

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"

If I change my image to mysql I get the error:

The server requested authentication method unknown to the client (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrations)

The server requested authentication method unknown to the client [caching_sha2_password]

My laravel .env looks like this:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=root
DB_PASSWORD=secret

I tried DB_HOST=database as well.

Any help would be great. Thanks!

OS: OSX