Got a Laravel 5.8 application spun up locally on Docker.
I can run the app on my browser, connect to the database on Sequel Pro, but when I try and migrate the database, I get the dreaded [2002] Connection refused
error.
I have set the mysql port to 3307 as I have another mysql container using 3306 for a different project. I don't want to have to keep stopping and starting docker for each project as I might be flicking between the 2 regularly, that's why I'm using different ports.
Here is the mysql section in the docker-compose file.
mysql:
image: mysql:5.7
ports:
- "3307:3306"
environment:
MYSQL_HOST: 127.0.0.1
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: forecast
MYSQL_USER: forecast
MYSQL_PASSWORD: secret
volumes:
- mysql:/var/lib/mysql
networks:
- forecast
Here is my .env file DB set up keys
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3307
DB_DATABASE=forecast
DB_USERNAME=forecast
DB_PASSWORD=secret
Also worth noting I am running the app on port 81, instead of 80 for the same reason. In my browser, I have to put {domain.testing}:81
which works.