I am recently moving away from Azure Mysql server to a local mysql server
on VM.
To protect from data losing, I store mysql files on my VM and use -v to
mount it to docker container.
docker run \ --name mysql \ --network wp-net \ --network-alias mysql-host \ -v $PWD/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root \ mysql:5.7.22
I would like to add all this files to git repo so that I can push them to
remote regularly. But when I tried to do git init, permission is denied.
The mysql files are created by mysql container, and the user and group are
both mysql. But when I view the files from the host machine. both user and
mysql are 999.
To resolve this issue, I changed the files’ group to my host user’s group.
chown -R 999:fennng mysql
Then I updated the files permissions so that the host user can access it.
Within the mysql folder, run
sudo find . -type d -exec chmod 775 {} \; sudo find . -type f -exec chmod 664 {} \;
Now both 999 and user’s in fennng group can access these files.
It’s not a great solution, but it’s much safer than setting everything to
777.
[image: image.png]