Support the ongoing development of Laravel.io →
Laravel Sail
Last updated by @geeky 1 year ago.
0
Solution

I finally solved it after mental frustation of more than a week. But it is very strange that no one was able to provide any answer in any forums, yes I tried all the famous forums possible.

I made sure that two users are added on my host(main computer) machine not the docker mysql, and I granted them full grant using mysql cli, there were 2 entries like these along with other entries

root | %
root | localhost

I ran following commands one after another. I don't know which commands exactly solved the problem as I am a beginner in docker and sail but here are my steps that I tried after which it started working.

I was getting Docker is not running. , so I tried following to make docker running.

sudo systemctl enable docker.service
sudo systemctl enable docker.socket

After that I tried sail up but it did not work, so ran following

sudo systemctl stop docker
sudo systemctl start docker
sudo systemctl disable docker.service
sudo systemctl enable docker.service
sail up

After that I rebooted my computer (I am on Ubuntu 22.04)

reboot

Removed some unnecessary files, also I got some failed error in docker service which I solved by running line 2&3 of the code below

sudo rm /etc/systemd/system/docker.service.d/override.conf
sudo systemctl reset-failed docker.service
sudo systemctl start docker.service
systemctl daemon-reload
sudo systemctl start docker.service
sail down
sail build --no-cache
sail up
php artisan config:clear

After that I migrated database and it worked

sail artisan migrate

After that

sudo systemctl enable docker
sail up
sail build
sail ps
sudo usermod -aG docker ${USER}

Removed daemon.json

sudo rm daemon.json

Removed old volumes

I think this was helpful

sail down --rmi all -v
sail up / (you can use sail up --no-cache)

Now mysql works on host computer port 3306 as well as other ports used for docker 3307,3308 simultaneously

0
Solution selected by @geeky

Update 2

I had to add platform: 'linux/x86_64' in docker-compose.yml file

mysql:
        image: 'mysql/mysql-server:8.0'
        platform: 'linux/x86_64'
        ports:
            - '${FORWARD_DB_PORT:-3307}:3306'
0

Sign in to participate in this thread!

Eventy

Your banner here too?

geeky geeky Joined 11 Feb 2018

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.