docker-compose-laravel icon indicating copy to clipboard operation
docker-compose-laravel copied to clipboard

mySQL Database

Open kyoukhana opened this issue 4 years ago • 8 comments

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

kyoukhana avatar Jun 25 '20 02:06 kyoukhana

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

AdrienPoupa avatar Jun 30 '20 13:06 AdrienPoupa

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"

SomePlayer avatar Aug 16 '20 13:08 SomePlayer

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....

dmitrij-schmidt avatar Sep 24 '20 21:09 dmitrij-schmidt

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.

sa-martinezr avatar Dec 01 '20 05:12 sa-martinezr

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?!

spartanatreyu avatar Apr 15 '21 06:04 spartanatreyu

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

igoralves1 avatar Jun 14 '21 13:06 igoralves1

same, I can not connect to mariadb via workbrench

Chuvantinh avatar Jun 03 '22 13:06 Chuvantinh

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

igoralves1 avatar Jun 03 '22 13:06 igoralves1

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.

aschmelyun avatar Nov 14 '22 05:11 aschmelyun