您好,登錄后才能下訂單哦!
今天就跟大家聊聊有關(guān)如何理解MySQL關(guān)于表名大小寫的參數(shù),可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。
查看現(xiàn)有的大小寫參數(shù)
[mysql@localhost percona]$ bin/mysql --defaults-file=/u01/mysql_data/my.cnf -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.17-11-log Percona Server (GPL), Release 11, Revision f60191c
mysql> show variables like '%lower%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| lower_case_file_system | OFF |
| lower_case_table_names | 1 |
+------------------------+-------+
2 rows in set (0.00 sec)
lower_case_table_names的值為1,代表數(shù)據(jù)庫的表名不區(qū)分大小寫
mysql> use test
Database changed
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| b |
| c |
| cpu_stat |
| p |
| support_his |
| t |
| v_t |
| z |
+----------------+
8 rows in set (0.00 sec)
mysql> select * from t;
+---+
| a |
+---+
| 1 |
| 2 |
| 3 |
+---+
3 rows in set (0.04 sec)
mysql> select * from T;
+---+
| a |
+---+
| 1 |
| 2 |
| 3 |
+---+
3 rows in set (0.00 sec)
這個參數(shù)是靜態(tài)參數(shù),不能在線修改,需要修改配置文件
mysql> set global lower_case_table_names=0;
ERROR 1238 (HY000): Variable 'lower_case_table_names' is a read only variable
關(guān)閉數(shù)據(jù)庫
[mysql@localhost percona]$ bin/mysqladmin -uroot -S /u01/mysql_data/mysql.sock shutdown -p
修改參數(shù)
[mysql@localhost percona]$ vim /u01/mysql_data/my.cnf
[mysqld]
lower_case_table_names = 0
重啟數(shù)據(jù)庫
[mysql@localhost percona]$ bin/mysqld_safe --defaults-file=/u01/mysql_data/my.cnf &
[mysql@localhost percona]$ bin/mysql --defaults-file=/u01/mysql_data/my.cnf -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.17-11-log Percona Server (GPL), Release 11, Revision f60191c
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use test
Database changed
mysql> show variables like '%lower%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| lower_case_file_system | OFF |
| lower_case_table_names | 0 |
+------------------------+-------+
2 rows in set (0.01 sec)
mysql> select * from T;
ERROR 1146 (42S02): Table 'test.T' doesn't exist
mysql> select * from t;
+---+
| a |
+---+
| 1 |
| 2 |
| 3 |
+---+
3 rows in set (0.02 sec)
注意:不建議在生產(chǎn)庫上面修改這個參數(shù),可能導(dǎo)致現(xiàn)有的庫不能使用
參數(shù)lower_case_file_system決定操作系統(tǒng)中文件名的大小寫,是只讀的,不能修改
[mysql@localhost percona]$ cd /u01/mysql_data/test/
[mysql@localhost test]$ ls
b.frm b.ibd c.frm c.ibd cpu_stat.frm cpu_stat.ibd db.opt p.frm p.ibd support_his.frm support_his.ibd t.frm t.ibd v_t.frm z.frm z.ibd
看完上述內(nèi)容,你們對如何理解MySQL關(guān)于表名大小寫的參數(shù)有進(jìn)一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注億速云行業(yè)資訊頻道,感謝大家的支持。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。