Some time ago I got an update in Docker Desktop in which WSL 2 was started to be used.
At first it all looked well, until I used MariaDB (MySQL) in a few of my apps.
I run MariaDB in Docker with the database’s db directories and config file mounted onto my Windows drive.
It turned out that the tables got created with capital case names through auto db migration in my apps.
I could not get the apps to work as the underlying data access library expected the table names to be lower case. When I looked in the logs of the MariaDB’s docker container and found that inside there was this line:
Warning: World-writable config file ‘/etc/mysql/my.cnf’ is ignored
I got curious about it and googled for the reason.
Apparently when MySQL finds that the config file is writable, it simply ignores it. And that meant that the line that I added to the config file:
[mariadb]
lower_case_table_names=1
was not applied.
The solution was to get into the container:
docker exec -it mariadb-container-name bash
and execute:
chmod 0444 /etc/mysql/my.cnf
to revoke write access.
I cleaned up the db directories (volumes mounted to the container) on Windows which already had all the tables stored there and reran the MariaDB’s Docker container.
I looked into logs (docker logs mariadb-container-name) and did not see the message from above anymore.
Right after that I ran my apps that in turn ran the db migration. This time the tables got created with lower case!