Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't set lower_case_table_names in MySQL 8.x on Windows 10

In MySQL 8.0.12 running on Windows 10, it seems impossible to set lower_case_table_names to 2, so as to achieve the appearance of mixed case DB and table names in Workbench. I realize that under the hood these objects may remain lower case, which is fine. But I want it to look right in Workbench, and I could always achieve this in previous versions of MySQL. When I attempt to do that and restart the service so it takes effect, the service crashes and stops. In the mysql logs I see this:

Different lower_case_table_names settings for server ('2') and data dictionary ('1').

Data Dictionary initialization failed.

This seems to be a common problem for a lot of people.

I read here that the solution is:

So lower_case_table_names needs to be set together with --initialize.

But I have no idea what that means, or how to set it at startup. I have googled all over and read several forum articles but I can't find clear instructions on how to resolve this.

like image 255
HerrimanCoder Avatar asked Oct 09 '18 19:10

HerrimanCoder


People also ask

What is lower_case_table_names in MySQL?

Use lower_case_table_names=0 on Unix and lower_case_table_names=2 on Windows. This preserves the lettercase of database and table names. The disadvantage of this is that you must ensure that your statements always refer to your database and table names with the correct lettercase on Windows.

How do I change case sensitive in MySQL?

Consequently, the case sensitivity of the underlying operating system plays a part in the case sensitivity of database and table names. One can configure how tables names are stored on the disk using the system variable lower_case_table_names (in the my. cnf configuration file under [mysqld]). Read the section: 10.2.

How do I make MySQL case sensitive in Windows?

For windows, it's available in the C:\ProgramData\MySQL\MySQL Server X.X directory. Open this file in administrator mode and set the lower_case_table_names variable value to 2.

What is the meaning of MySQL configuration line lower_case_table_names 1?

Initialize with lower_case_table_names = 1 This means, you should update the MySQL configuration file with the desired value of lower_case_table_names before the first start. The default location for the MySQL configuration file is /etc/my.cnf .


1 Answers

I figured it out. When installing MySQL Server 8.0.x, you have to check Show Advanced and Logging Options ...

enter image description here

...so that you can get to this screen:

enter image description here

Then you select Preserve Given Case, which is not the default. Hey MySQL developers: This setting should be on the main path, not buried in the optional advanced path.

===============================

Notes added on 9/25/2021:

  • This Preserve Given Case option can only be selected on first-time installation. You cannot go back and choose it later. Editing the config file will only cause errors. Attempting to upgrade or modify the install results in readonly options for this item.
  • If you already have MySQL installed without this desired option, you'll need to completely uninstall it and reinstall it.
  • As of MySQL 8.0.26, these steps are still valid.

===============================

like image 78
HerrimanCoder Avatar answered Sep 30 '22 06:09

HerrimanCoder