0

After Laravel installation by sail and docker on windows, I run the server by:

./vendaor/bin/sail up -d

and this is the containers:

enter image description here

I can't connect to MySQL by user: root and password and port 3306

docker exec -it app-mysql-1 mysql -u root -p

I delete the app-mysql-1 from app containers and Run a MySQL image but problem still exists and I can't connect to MySQL and make or migrate.

I can find the auto generated MySQL password and can change it but can't connect and use this one in app containers

enter image description here

How I can connect to MySQL in the app containers?

Mehdi Yaghoubi
  • 561
  • 3
  • 8
  • 24

1 Answers1

3

If you didn't change the default Sail database user then you should use:

User: sail
Password: password

And in ./.env:

DB_USERNAME=sail
DB_PASSWORD=password
Thomas
  • 8,426
  • 1
  • 25
  • 49
  • Worked! thankyou, I can connect but can't migrate by ./vendor/bin/sail PHP artisan migrate, get the error: SQLSTATE[HY000] [2002] No such file or directory (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE'). I made a bb named app DB_CONNECTION=mysql DB_HOST=localhost DB_PORT=3306 DB_DATABASE=app DB_USERNAME=sail DB_PASSWORD=password but get error ! – Mehdi Yaghoubi Apr 29 '22 at 15:35
  • Default MySQL username and password, Laravel Sail. I couldn't find the real answer to this question ANYWHERE, just workarounds. WTH. Thanks!! – FredTheWebGuy Feb 05 '23 at 17:55