Linux下設定MySQL表名不區分大小寫

來源:互聯網
上載者:User

Linux下設定MySQL表名不區分大小寫

情景:公司近期在將資料庫從Oracle轉為MySQL,由於之前在Oracle中表名是不區分大小寫,因此到MySQL中就出現了找不到表的問題,經上網查詢,發現在Linux下MySQL的表名是區分大小寫,但是有參數可以使其不區分大小寫。具體操作如下:

一、Linux中MySQL大小寫詳情:
1、資料庫名嚴格區分大小寫
2、表名嚴格區分大小寫
3、表的別名嚴格區分大小寫
4、變數名嚴格區分大小寫
5、列名在所有的情況下均忽略大小寫
6、列的別名在所有的情況下均忽略大小寫

二、設定MySQL表名不區分大小寫
1、切換到root使用者
$ su - root

2、修改/etc/my.cof設定檔,
# sed -i '/mysqld/a\lower_case_table_names=1' /etc/my.cnf

lower_case_table_names參數詳解:

  • 0:區分大小寫
  • 1:不區分大小寫

3、重啟MySQL
# service mysqld restart

4、查看mqsql參數
# mysql -uroot -p
> show variables like "%case%" ;
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| lower_case_file_system | OFF  |
| lower_case_table_names | 1    |
+------------------------+-------+
2 rows in set (0.00 sec)

三、其他

在Windows中,MySQL一直都是不區分大小寫。

本文永久更新連結地址:

相關文章

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.