Install MySQL 8 on Linux with lower_case_table_names = 1

MySQL shops numerous files on disk. Even in MySQL 8 where the information dictionary is kept in InnoDB tables, there are still all the tablespace files. Various file system act in a different way, and one specific difficulty is case level of sensitivity. On Microsoft Windows, the case does not matter, on Linux the case is essential, and on macOS the case of the file names is maintained however the os by default makes it appear like it is case insensitive.

Which convention that is the proper depends upon your individual choice and utilize case. In between case level of sensitivity and case insensitivity, it generally comes down to whether mydb, mydb, and mydb must be the exact same identifier or 3 various ones. Given that MySQL initially counted on the file system for its information dictionary, the default was to depend on the case level of sensitivity of the file system. The choice lower_case_table_names was presented to bypass the behaviour. The most typical usage is to set lower_case_table_names to 1 on Linux to present case insensitive schema and table names.

 Dolphin with lower_case_table_names

This blog site will initially go over how lower_case_table_names operate in MySQL 8 –– it is not the like in earlier variations. It will be revealed how MySQL 8 can be initialized on Linux to utilize case insensitive identifiers.


To utilize case insensitive identifiers in MySQL 8, the main point is that you should set lower_case_table_names = 1 in your MySQL setup file prior to you initialize the information directory site (this takes place on the very first start when utilizing systemd).

.MySQL 8 and lower_case_table_names.

In MySQL 8, it is no longer permitted to alter the worth of the lower_case_table_names choice after the information directory site has actually been initialized. This is a security function –– as explained in the referral handbook:

.When the server was initialized, #ppppp> It is forbidden to begin the server with a lower_case_table_names setting that is various from the setting utilized. The limitation is required due to the fact that collations utilized by different information dictionary table fields are based upon the setting specified when the server is initialized, and rebooting the server with a various setting would present disparities with regard to how identifiers are purchased and compared.

If you attempt to begin MySQL 8 with a various worth of lower_case_table_names than MySQL was initialized, you will get a mistake like (from the MySQL mistake log):

.2019-04-14T03:57:19.095459 Z 1 [MISTAKE] [MY-011087] [Server] Various lower_case_table_names settings for server (‘ 1’) and information dictionary (‘ 0’).2019-04-14T03:57:19.097773 Z 0 [MISTAKE] [MY-010020] [Server] Information Dictionary initialization stopped working.2019-04-14T03:57:19.098425 Z 0 [MISTAKE] [MY-010119] [Server] Terminating.2019-04-14T03:57:20.784893 Z 0 [System] [MY-010910] [Server]/ usr/sbin/mysqld: Shutdown total (mysqld 8.0.15) MySQL Community Server – GPL.

So what are the actions to initialize MySQL 8 with lower_case_table_names = 1? Let’’ s go through them.

. Setting up MySQL 8 with Case Insensitive Identifier Names.

There are numerous methods to set up MySQL 8 on Linux. The actions that will be revealed here are:

.Set up the MySQL repository.Eliminate previous setups of MySQL or among its forks.Tidy the information directory site.Set up MySQL 8.Initialize with lower_case_table_names = 1.

The example commands are from Oracle Linux 7 and likewise deals with Red Hat Enterprise Linux (RHEL) 7 and CentOS 7. The MySQL YUM repository will be utilized. On other Linux circulations the actions will in basic be various, however associated.

.1. Set Up the MySQL Repository.

MySQL supplies repositories for a number of Linux circulations for the Community Edition. You can download the repository meaning files from MySQL Community Downloads . The files can likewise be accessed straight. For this example the YUM repository meaning will be downloaded utilizing wget and after that set up utilizing yum:

.shell$ wget– 2019-04-14 12:28:31–….HTTP demand sent out, waiting for reaction … 200 OK.Length: 25892 (25K) [application/x-redhat-package- supervisor] Conserving to: ‘‘ mysql80-community-release-el7-2. noarch.rpm ’. 100 %[===============================================> =========== =>] 25,892–.- K/s in 0.01 s. 2019-04-14 12:28:33( 1.76 MB/s) – ‘‘ mysql80-community-release-el7-2. noarch.rpm ’ conserved [25892/25892]shell$ yum set up mysql80-community-release-el7-2. noarch.rpm….Dependencies Resolved.=====================================================================================================.Bundle Arch Version Repository Size.=====================================================================================================.Setting up:.mysql80-community-release noarch el7-2/ mysql80-community-release-el7-2. noarch 31 k.Transaction Summary.=====================================================================================================.Set up 1 Package.Overall size: 31 k.Installed size: 31 k.Is this okay [y/d/N]: y.Downloading plans:….Installing: mysql80-community-release-el7-2. noarch 1/1.Verifying: mysql80-community-release-el7-2. noarch 1/1.Set up:.mysql80-community-release. noarch 0: el7-2.Total!If present) and its files, #ppppp> You can now eliminate the previous setup (.

.2. Eliminate Previous Installations.

MySQL or among its forks might have been set up in advance. This might even take place as a dependence of another bundle. You must never ever have more than one MySQL or fork set up utilizing the bundle system (yum or rpm on Oracle Linux, RHEL, and CentOS).


If you require to set up various variations of MySQL side by side, utilize the tarball circulations.

You wish to uninstall the existing bundles in such a method that you do not get rid of the programs that depend on it –– otherwise you will need to re-install those later on. One choice is to utilize the rpm command with the– nodeps choice. On Oracle Linux 7, RHEL 7, and CentOS 7 this might appear like:

.shell$ rpm -e– nodeps mariadb-server-5.5.56 -2. el7.x86 _ 64 mariadb-5.5.56 -2. el7.x86 _ 64 mariadb-libs-5.5.56 -2. el7.x86 _ 64.

You can discover which plans are set up utilizing rpm -qa and pass the output through grep to look for the bundles of interest.

The next action is to clear out any existing files left.

.3. Tidy the Data Directory.

In order to have the ability to initialize MySQL in action 5., the information directory site should be empty. You can select to utilize a non-default area for the information directory site, or you can re-use the default place which utilize/ var/lib/mysql. Make sure you back it up initially if you desire to protect your old information directory site!


Important: If you wish to keep your old information files, ensure you back them up prior to continuing! All existing files will be completely lost throughout this action.

The information directory site might have been eliminated in action 2., however if it has not, you can eliminate it utilizing the following command:

.shell$ rm -rf/ var/lib/mysql.

Optionally, you can likewise eliminate the mistake log, and if you keep files outside the information directory site (for instance the binary log files or InnoDB log files), you ought to likewise eliminate those. The mistake log lies in/ var/log/; for other files, you will require to inspect your setup file (generally/ etc/my. cnf).

You are now all set to set up the MySQL 8.

.4. Set up MySQL 8.

You can pick in between a number of plans and spot releases (upkeep releases). It is suggested to set up the most recent spot release. You can see from the release notes which release is the most recent. By default, yum will likewise set up the current release. Which bundles you wish to set up depends upon your requirements. The MySQL recommendation handbook consists of a list of the offered plans with a description of what they consist of.

In this example, the following bundles will be set up:

.mysql-community-client: Client applications such as the mysql command-line customer.mysql-community-common: Some typical apply for MySQL programs.mysql-community-libs: Shared libraries utilizing the most recent variation of the API.mysql-community-libs-compat: Shared libraries utilizing the variation of the API representing what RPM plans from the Oracle Linux/RHEL/CentOS repositories that depend upon MySQL utilizes. For Oracle Linux 7, RHEL 7, and CentOS 7 this implies variation 18 (e.g. The real MySQL Server.mysql-shell: MySQL Shell –– the 2nd generation command-line customer with devops assistance. This RPM is not noted in the above recommendation as it is not part of the MySQL Server RPM package, nevertheless when utilizing the MySQL YUM repository, it can be set up in the very same method as the other RPMs.

The yum command therefore ends up being:

.shell$ yum set up mysql-community- mysql-shell….Dependencies Resolved.=====================================================================================================.Plan Arch Version Repository Size.=====================================================================================================.Setting up:.mysql-community-client x86_64 8.0.15-1. el7 mysql80-community 25 M.mysql-community-common x86_64 8.0.15-1. el7 mysql80-community 566 k.mysql-community-libs x86_64 8.0.15-1. el7 mysql80-community 2.2 M.mysql-community-libs-compat x86_64 8.0.15-1. el7 mysql80-community 2.1 M.mysql-community-server x86_64 8.0.15-1. el7 mysql80-community 360 M.mysql-shell x86_64 8.0.15-1. el7 mysql-tools-community 9.0 M.Transaction Summary.=====================================================================================================.Set up 6 Packages.Overall download size: 400 M.Installed size: 1.8 G.Is this okay [y/d/N]: y.Downloading plans:….Retrieving secret from file:/// etc/pki/rpm-gpg/ RPM-GPG-KEY-mysql.Importing GPG crucial 0x5072E1F5:.Userid: “MySQL Release Engineering <“. Finger print: a4a94068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5. Bundle: mysql80-community-release-el7-2. noarch( set up). From:/ etc/pki/rpm-gpg/ RPM-GPG-KEY-mysql. Is this okay [y/N]: y. Running deal check. Running dealtest. Deal test prospered. Running deal.Setting up: mysql-community-common-8.0.15 -1. el7.x86 _ 64 1/6.Setting up: mysql-community-libs-8.0.15 -1. el7.x86 _ 64 2/6.Setting up: mysql-community-client-8.0.15 -1. el7.x86 _ 64 3/6.Setting up: mysql-community-server-8.0.15 -1. el7.x86 _ 64 4/6.Setting up: mysql-community-libs-compat-8.0.15 -1. el7.x86 _ 64 5/6.Putting up: mysql-shell-8.0.15 -1. el7.x86 _ 64 6/6.Verifying: mysql-community-libs-compat-8.0.15 -1. el7.x86 _ 64 1/6.Verifying: mysql-community-common-8.0.15 -1. el7.x86 _ 64 2/6.Verifying: mysql-community-server-8.0.15 -1. el7.x86 _ 64 3/6.Verifying: mysql-shell-8.0.15 -1. el7.x86 _ 64 4/6.Verifying: mysql-community-client-8.0.15 -1. el7.x86 _ 64 5/6.Verifying: mysql-community-libs-8.0.15 -1. el7.x86 _ 64 6/6.Set up:.mysql-community-client. x86_64 0:8.0.15 -1. el7 mysql-community-common. x86_64 0:8.0.15 -1. el7.mysql-community-libs. x86_64 0:8.0.15 -1. el7 mysql-community-libs-compat. x86_64 0:8.0.15 -1. el7.mysql-community-server. x86_64 0:8.0.15 -1. el7 mysql-shell. x86_64 0:8.0.15 -1. el7.Total!

Notice how the GPG secret for the MySQL YUM repository is downloaded, and you are asked for to validate it is the right secret. This takes place, since it is the very first time the repository is utilized. You can likewise by hand include the GPG secret utilizing the directions in Signature Checking Using GnuPG .

You are now all set to the last action: beginning and setting up MySQL Server for the very first time.

.5. Initialize with lower_case_table_names = 1.

As pointed out in the intro to this blog site, you require to guarantee that lower_case_table_names is set up when MySQL initializes its information directory site. It will occur instantly when you begin MySQL with an empty information directory site when you utilize systemd to begin MySQL. This suggests, you ought to upgrade the MySQL setup file with the preferred worth of lower_case_table_names prior to the very first start.

The default area for the MySQL setup file is/ etc/my. cnf. Open this file with your preferred editor and make sure the line lower_case_table_names = 1 is noted in the [mysqld] group:

.[mysqld] lower_case_table_names = 1.

Optionally, you can make other modifications to the setup as required.


Other than a couple of capability settings such as innodb_buffer_pool_size and the setup of the InnoDB renovate logs, the default setup is a great beginning point for a lot of setups.

Now, you can begin MySQL:

.shell$ systemctl start mysqld.

This will take a little time as it consists of initializing the information directory site. When MySQL has actually begun, you can recover the momentary password for the root account from the MySQL mistake log:

.shell$ grep ‘short-lived password’/ var/log/mysqld. log.2019-04-14T03:29:00.122862 Z 5 [Keep in mind] [MY-010454] [Server] A short-lived password is produced for root@localhost: aLxwMUQr% 7C,.

The short-lived password is arbitrarily produced throughout the initialization to prevent MySQL being entrusted a recognized default password. Utilize this momentary password to visit and set your irreversible root password:

.shell$ mysql– user= root– host= localhost– password.Get in password:.Invite to the MySQL screen. Commands end with; or g.Your MySQL connection id is 9.Server variation: 8.0.15.Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights booked.Oracle is a signed up hallmark of Oracle Corporation and/or its.affiliates. Other names might be hallmarks of their particular.owners.Type ‘aid;’ or ‘ h’ for assistance. Type ‘ c’ to clear the existing input declaration.mysql>> ALTER USER root@localhost IDENTIFIED BY ‘n3w_$tr0ng_P@s$word’;.Inquiry OK, 0 rows impacted (0.12 sec).

By default for RPM setups, MySQL has the password recognition element set up utilizing the MEDIUM strength policy. This implies you will require to utilize a reasonably strong password.

You can now validate that MySQL utilizes case insensitive schema and table identifiers:

.mysql>> SELECT @@ global.lower _ case_table_names;.+ ———————————+.|@@ global.lower _ case_table_names |+ ———————————+.|1 |+ ———————————+.1 row in set (0.00 sec).mysql>> SELECT VARIABLE_SOURCE, VARIABLE_PATH.FROM performance_schema. variables_info.WHERE VARIABLE_NAME=’lower_case_table_names’;.+ —————–+ —————+.|VARIABLE_SOURCE|VARIABLE_PATH |+ —————–+ —————+.|INTERNATIONAL |/ etc/my. cnf |+ —————–+ —————+.1 row in set (0.01 sec).mysql>> CREATE SCHEMA db1;.Inquiry OK, 1 row impacted (0.03 sec).mysql>> usage DB1;.Database altered.mysql>> CREATE TABLE t1 (id int anonymous NOT NULL PRIMARY KEY);.Inquiry OK, 0 rows impacted (0.47 sec).mysql>> INSERT INTO T1 VALUES (1 );.Question OK, 1 row impacted (0.05 sec).mysql>> SELECT * FROM t1;.+–+.|id |+–+.|1 |+–+.1 row in set (0.01 sec).

The question in lines 9-11 questions what the source of the worth of the lower_case_table_names choice is. This reveals that the worth of 1 (from the previous inquiry) is gotten from the/ etc/my. cnf file. The remainder of the questions demonstrate how the db1 schema and the db1.t1 table can be accessed both utilizing lower and upper case.

That is it. When a schema item was produced, now you can utilize MySQL Server without having to keep in mind which case was utilized.

Read more:

Leave a Comment

Your email address will not be published. Required fields are marked *