docker-compose-laravel
docker-compose-laravel copied to clipboard
mySQL Database
One thing to note you should add in the Readme is the IP Address of the mySQL database needs to be the local network ip other wise the database will not connect. I tried with 127.0.0.1 and localhost didn't work
The DB_HOST
should be the name of the service, ie, mysql
: https://github.com/aschmelyun/docker-compose-laravel/blob/main/docker-compose.yml#L26
ah nice, as a complete noob to docker, this would be good info for the article at https://dev.to/aschmelyun/the-beauty-of-docker-for-local-laravel-development-13c0
oops: it was in the article already, I just missed it. Even thought bold and all
@kyoukhana May I suggest changing your issue title to something more descriptive. Error give when DB_HOST is wrong is "SQLSTATE[HY000] [2002] No such file or directory"
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
in .env file should solve the problem. Or maybe adjust docker-compose.yml beforehand....
DB_CONNECTION=mysql DB_HOST=mysql DB_PORT=3306 DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret
in .env file should solve the problem. Or maybe adjust docker-compose.yml beforehand....
This sould be on the main README.md, that it's necesssary to set up the Laravel .env file as that.
DB_CONNECTION=mysql DB_HOST=mysql DB_PORT=3306 DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret
in .env file should solve the problem. Or maybe adjust docker-compose.yml beforehand....
Holy butt-fuck and balls, why is that not in the readme?!
I also had thi serror:
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')
It was solved changing the DB_HOST=0.0.0.0
or DB_HOST=127.0.0.1
to DB_HOST=mysql
This is what I have in the .env
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
same, I can not connect to mariadb via workbrench
same, I can not connect to mariadb via workbrench
Try to change the host address 0.0.0.0 or 127.0.0.1 and take a look on the port
I've updated the README with some details about the database. The host for MySQL for the Laravel application should be mysql
. Here are the details for it:
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
If you are connecting from your computer through something like TablePlus or a SQL workbench app, the host will be 127.0.0.1
with the standard MySQL port.