Detailed explanation of MySQL table name case-insensitive configuration method

Detailed explanation of MySQL table name case-insensitive configuration method

By default, MySQL in Linux distinguishes between upper and lower case table names. Whether MySQL is case sensitive is determined by the parameter lower_case_table_names, where:

1) lower_case_table_names = 0

Case-sensitive (not case sensitive), this is the default setting. After this setting, it does not matter whether the table names created in MySQL contain uppercase letters or not, they can all be read and referenced normally.

2) lower_case_table_names = 1

Case-insensitive (i.e. case sensitive). After this setting, the table names are saved in lowercase on the hard disk, and MySQL converts all table names to lowercase for storage and search. This behavior also applies to database names and table aliases .

That is to say, after MySQL is set to be case-insensitive, when creating a database or table, no matter if uppercase letters are used when creating it, it will be forced to be saved in lowercase after the creation is successful!

The case rules for MySQL database names, table names, column names, and aliases under Linux are as follows:

1) Database names and table names are strictly case-sensitive;

2) Table aliases are strictly case-sensitive;

3) Column names and column aliases are case-insensitive in all cases;

4) Variable names are also strictly case-sensitive;

5) MySQL is not case-sensitive under Windows, but is case-sensitive by default under Linux.

6) If you want to distinguish between uppercase and lowercase letters when querying, you need to set the BINARY attribute for the field value. There are several ways to set it:
a) Setting at creation time:
CREATE TABLE T(A VARCHAR(10) BINARY);
b) Use alter to modify

Therefore, in order to ensure that programs and databases can run normally in different operating systems, the best way is to convert them to lowercase when designing tables! !

Modify mysql to be case-insensitive:

mysqladmin -uroot -p shutdown //Shut down the database in safe mode

Modify my.cnf //Add the following line of settings
.....
[mysqld]
lower_case_table_names=1
.....

Start mysql

The above detailed explanation of the configuration method of ignoring case in MySQL table names is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Notes on MySQL case sensitivity
  • MySQL character types are case sensitive
  • How to set mysql to case insensitive
  • Analysis of problems caused by MySQL case sensitivity
  • How to solve the problem of case insensitivity in MySQL queries
  • MySQL database case sensitivity issue
  • Linux system MySQL forgotten password, reset password, ignore the case of table and column names
  • How to distinguish uppercase and lowercase letters in strings when querying MySQL
  • MySql query case insensitive solution (two)
  • MySQL table name case selection

<<:  How to use cookies to remember passwords for 7 days on the vue login page

>>:  Install Mininet from source code on Ubuntu 16.04

Recommend

18 Amazing Connections Between Interaction Design and Psychology

Designers need to understand psychology reading n...

Vue Element-ui table realizes tree structure table

This article shares the specific code of Element-...

Vue basic instructions example graphic explanation

Table of contents 1. v-on directive 1. Basic usag...

How to install git on linux

1. Introduction Git is a free, open source distri...

CSS and CSS3 flexible box model to achieve element width (height) adaptation

1. CSS realizes fixed width on the left and adapt...

MySQL 5.7 and above version download and installation graphic tutorial

1. Download 1. MySQL official website download ad...

Various methods to restart Mysql under CentOS (recommended)

1. MySQL installed via rpm package service mysqld...

JS asynchronous code unit testing magic Promise

Table of contents Preface Promise chaining MDN Er...

MYSQL database GTID realizes master-slave replication (super convenient)

1. Add Maria source vi /etc/yum.repos.d/MariaDB.r...

Example analysis of mysql shared lock and exclusive lock usage

This article uses examples to illustrate the usag...

Detailed explanation of the calculation method of flex-grow and flex-shrink in flex layout

Flex(彈性布局) in CSS can flexibly control the layout...

Installation tutorial of MySQL 5.7.17 zip package version under win10

The installation tutorial of mysql5.7.17 is share...

Teach you how to install mysql database on Mac

Download MySQL for Mac: https://downloads.mysql.c...

MySQL efficient query left join and group by (plus index)

mysql efficient query MySQL sacrifices group by t...

Practical example of Vue virtual list

Table of contents Preface design accomplish summa...