Reputation: 6955
I just upgraded to Docker Desktop 2.4 on MacOS, from version 2.3. Suddenly none of my mysql containers will start. The logs show this as the reason:
Different lower_case_table_names settings for server ('2') and data dictionary ('0').
Data Dictionary initialization failed.
Aborting
The database files are mounted in a volume on my host machine, so that they persist between restarts.
I finally figured out why. Posting in order to answer.
Upvotes: 69
Views: 27872
Reputation: 520
I just wanted to add this answer as I encountered the same issue in different context, and wanted to let everyone know how I solved it
The Problem:
So, I had a MySQL container running on my local machine, and it didn't have any persistent volume mounted. This basically means that if I killed the container, I would lose all the data. Since there was some useful data in the container, I didn't want that to happen.
Here's what I did:
I got into the container and copied the MySQL data directory to the host machine. Then, I killed the container and started a new one, mounting a volume with the copied directory on the host. To my surprise, I encountered the issue mentioned in the question as Windows and Linux systems have different case sensitivities for directories.
How did I solve it?
I created another directory, made it case-insensitive with the command
fsutil file setCaseSensitiveInfo ./ enable
and copied the content from the previously copied directory into it. After that, everything started working.
Upvotes: 0
Reputation: 21
A small addition to Loic's H answer. Suppose your mapping is something like this:
docker run --name your_container_name ... -v //d/MySqlDockerData:/var/lib/mysql ...
if your try
fsutil file setCaseSensitiveInfo d:\MySqlDockerData
you will get an error "The directory is not empty"
To get around this follow these steps:
voila
Upvotes: 1
Reputation: 348
Docker removed this option on the recent updates , i manage to solve this issue on windows by doing this
Run a shell as administrator:
go to your local mounted mysql volume and run
fsutil file setCaseSensitiveInfo ./ enable
credits to https://github.com/docker/for-win/issues/12384#issuecomment-972845031
Upvotes: 3
Reputation: 144
As workaround on Windows OS I disabled WSL in Docker Desktop and it helped me
Update. After last Docker Desktop Updates I was forced to set Windows directory with DB data as case sensitive
Upvotes: 0
Reputation: 512
Another option is to create a case sensitive APFS volume using Disk Utility.
Unlike a partition, it is possible to share the free space, so you don't need to worry about reserving enough space to run your database.
Then create a symlink from your project to your case sensitive volume.
cd ~/my-project
ln -s /Volumes/MySQL/project-db mysql
Upvotes: 5
Reputation: 3282
With the latest docker you can disable the gRPC Fuse for file sharing. (the gRPC Fuse setting is causing this problem, it's incompatible with the data dictionary of 0)
This fixes the problem... You can stop here if you're happy, but to use the new filesystem you can:
UPDATE
Since version 2.5, the setting has been moved to the 'experimental features' page:
Upvotes: 126
Reputation: 6955
The lower_case_table_names
setting tells mysql how to store and compare table names. If the file system the database is stored on is itself not case-sensitive, it will force you to use lower_case_table_names=2
.
The MacOS filesystem is not case-sensitive. Up until Docker Desktop 2.4, the mysql container apparently didn't know that the underlying filesystem is not case-sensitive and set lower_case_table_names=0
. However, since upgrading to Docker 2.4, Docker is apparently smarter about how it mounts volumes. So the container realizes its running on a case-insensitive filesystem and forces lower_case_table_names=2
. The problem is that you cannot change the value of lower_case_table_names
after initializing the database. And since the data dictionary was initialized with lower_case_table_names=0
, it will fail to initialize with the server set to lower_case_table_names=2
.
The only solution I've found is to:
UPDATE: See this answer below for a better solution. There is apparently no need to downgrade. You can instead disable "gRPC Fuse for filesharing", backup the database, re-enable gRPC fuse, delete your database data folder, and restore the database from backup.
Upvotes: 25