2

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

1 Answer 1

2

I guess you have some old data in dbdata folder and they are causing a problem. If you don't need old DB, then just delete the content of this folder and start mysql container from the scratch. Another problem is a port. You are publishing MySQL on the port 33061, so Laravel should be configured with DB_PORT=33061.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.