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

mysql is always restarting. "Changing ownership of '/var/lib/mysql/mysql.sock': No such file or directory"

Open t-franz opened this issue 2 years ago • 8 comments

Describe the bug The container status for mysql8 is "Restarting ...". I can't connect to MySQL

which Branch / PHP Version are you using ? docker-compose.yml: Version 3 php8 mysql8

Steps to reproduce Followed the instructions and it works in the first run:

git clone https://github.com/sprintcube/docker-compose-lamp.git
cd docker-compose-lamp
cp sample.env .env
docker-compose up -d

I can access http://localhost and phpMyAdmin at http://localhost:8080/ Then i stopped and started the containers:

docker compose stop
docker compose start

... and mysql stopped working: mysql is cycling and tries to restart. desktop

I can access http://localhost, but it shows errors: error

The log file for the mysql8-Container:

2022-11-01 12:34:48+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.31-1.el8 started.
[Multiple Times]
chown: changing ownership of '/var/lib/mysql/mysql.sock': No such file or directory
[Multiple Times]

Then i removed the content of the data-folder: rm -rf data/* And started it again: docker compose start

And it works again! How can i solve this, without loosing everything inside the data-folder?

Expected behavior After stopping and starting the containers, everything should work the same.

Desktop (please complete the following information): MacOS: 11.7 Docker Desktop: 4.13.0 Docker Compose: 1.29.2

docker -v
Docker version 20.10.20, build 9fdeb9c

Additional context This seems to be a quite similar problem to #91 – but it didn't help me. (Please ignore my last comment inside that closed issue.) I'm sorry: It's my first time with Docker. I used MAMP until now and i wanted to switch to Docker ... :-( Thank you for your help!

t-franz avatar Nov 01 '22 13:11 t-franz

I'm not able to reproduce this on macos. Is some of our mac users able to double check pls ?

MrOffline77 avatar Dec 18 '22 18:12 MrOffline77

@t-franz The following worked for me. Add to docker-compose.yml at database:

user: mysql

wschern avatar Dec 30 '22 21:12 wschern

Thank you for your help. I changed the lines to:

  database:
    user: mysql
    [...]

But i still can't connect to the database. (In the meantime i changed to another environment and that is working.)

t-franz avatar Dec 31 '22 13:12 t-franz

@t-franz I have the same problem, did you solve it?

ctechdev avatar Apr 05 '23 09:04 ctechdev

@ctechdev No, i'm sorry. I switched to ddev and don't use lamp any more.

t-franz avatar Apr 16 '23 17:04 t-franz

I'm not able to reproduce this on macos. Is some of our mac users able to double check pls ?

to reproduce the error just change PHPVERSION=php74 DATABASE=mysql57 in the env file, with an installation with default values the error is not generated, I'm trying to build the development environment with these variables and there is no way to make it work

ctechdev avatar Apr 19 '23 17:04 ctechdev

I could start the stack with php74 and mysql57 without any issues. BUT if you change the settings and rebuild the images you have to delete the old data in the./data/mysqldirectory wich is mounted into the container by bind mounting. (Of course you could mount another directory too if you want to keep that files). If you don't delete that files, the new database container will get issues with that because the databases are not compatible over the diffrent versions.

H3avy6unner avatar Apr 24 '23 00:04 H3avy6unner

I could start the stack with php74 and mysql57 without any issues. BUT if you change the settings and rebuild the images you have to delete the old data in the./data/mysqldirectory wich is mounted into the container by bind mounting. (Of course you could mount another directory too if you want to keep that files). If you don't delete that files, the new database container will get issues with that because the databases are not compatible over the diffrent versions.

thanks a lot, I had problems with phpmyadmin because I was really changing the version of mysql and php, after deleting the data/mysql folder, the build started working

artemsites avatar Jan 20 '24 08:01 artemsites