Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

peffraimidis's avatar

Laravel sail change db username and password?

Hello I downloaded a fresh laravel 8 application and I am using sail By default the .env file that was created has

DB_USERNAME=sail DB_PASSWORD=password

but I need to change these and use my own

How is this possible?

for now I am simply trying to change them to root/root and I get Access denied for user 'root'@...

0 likes
10 replies
neilstee's avatar

@pefremidis because there is no root/root on your Sail setup.

May I know why you are changing the defaults? Did you intend to use a MySQL DB outside Sail?

peffraimidis's avatar

I have multiple sites that use sail and each one has its own defaults for username and password. So when I am changing projects it is annoying to switch credentials in order to connect with table plus for example

neilstee's avatar

@pefremidis Sail only gets the credentials on your .env file, so change your .env file first and rebuild your sail using:

sail build --no-cache
sail up -d

And root/root should work.

neilstee's avatar
neilstee
Best Answer
Level 34

@pefremidis hmm, it must be the volume, try:

sail down -v
sail build --no-cache
sail up -d
18 likes
sr57's avatar

I don't understand your pb, therei is nothing special to do normally, the values you define in .env are taken by docker compose and so by sail cde

It works without pb for me with postgresql.

sinisimattia's avatar

If anyone is still having issues I'd like to add on top of @neilstee's answer.

sail down -v
sail up -d
sail artisan config:cache
sail artisan migrate
5 likes

Please or to participate in this conversation.