linux環境下mysql 大小寫敏感解決辦法,linuxmysql

來源:互聯網
上載者:User

linux環境下mysql 大小寫敏感解決辦法,linuxmysql

1、Linux下mysql安裝完後是預設:區分表名的大小寫,不區分列名的大小寫;

 

2、用root帳號登入後,在/etc/my.cnf中的[mysqld]後添加添加lower_case_table_names=1,重啟MYSQL服務,這時已設定成功:不區分表名的大小寫;

lower_case_table_names參數詳解:

lower_case_table_names= 0

 

其中 0:區分大小寫,1:不區分大小寫

  MySQL在Linux下資料庫名、表名、列名、別名大小寫規則是這樣的:

1、資料庫名與表名是嚴格區分大小寫;

2、表的別名是嚴格區分大小寫;

3、列名與列的別名在所有的情況下均是忽略大小寫;

4、變數名也是嚴格區分大小寫;

MySQL在Windows下都不區分大小寫。

 

3、如果想在查詢時區分欄位值的大小寫,則:欄位值需要設定BINARY屬性,設定的方法有多種:

A、建立時設定:

CREATE TABLE T(

A VARCHAR(10) BINARY

);

B、使用alter修改:

ALTER TABLE`tablename` MODIFY COLUMN `cloname` VARCHAR(45) BINARY;

C、mysql tableeditor中直接勾選BINARY項。

 

 


 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.