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.
Here are the steps you can follow to install the Dockerhub MySQL Container: Step 1: Pull the Docker Image for MySQL. Step 2: Deploy and Start the MySQL Container. Step 3: Connect with the Docker MySQL Container.
By default, Docker stores data in its internal volume. You will see the /var/lib/mysql mounted in the internal volume. You can also change the location of the data directory and create one on the host. Having a volume outside the container allows other applications and tools to access the volumes when needed.
Understanding MySQL Docker. Running MySQL with Docker containers is a widely used mechanism, especially for the microservices architecture where usually each microservice works with its own database/tables and the isolated integration/component tests can be executed on the containerized versions of the databases.
Docker Desktop currently supports macOS Catalina, macOS Big Sur, and macOS Monterey. At least 4 GB of RAM. VirtualBox prior to version 4.3. 30 must not be installed as it is not compatible with Docker Desktop.
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With