0

I have installed a fresh Laravel 8 Project using sail https://laravel.com/docs/8.x/installation#getting-started-on-macos

I followed the guide. First ran this

curl -s "https://laravel.build/example-app" | bash

Then this

./vendor/bin/sail up

But now I have difficulty connecting using mysql client. This is the command that I'm trying to execute

mysql -u sail -D example_app -h localhost -P 3306 -p

I get the following error

ERROR 1045 (28000): Access denied for user 'sail'@'localhost' (using password: YES)

2 Answers2

0

The .env file at the root of the project – docker-compose.yml automatically detects and imports the content of this file. For instance, in the MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' line, the container's MYSQL_ROOT_PASSWORD environment variable will receive the value of DB_PASSWORD from the .env file.

By default these are sail for the username and password for the pass. Are you passing that password when connecting?

This is a really good article i followed to get more insights: https://tech.osteel.me/posts/you-dont-need-laravel-sail

0

Use DB_HOST as 'mysql' in .env file.

Kushal
  • 2,605
  • 4
  • 22
  • 23