一、修改文件屬性
# 下面是我修改lower_case_table_names屬性不生效的步驟菲语;
# 1茂附、進入到mysql配置文件;
vi /etc/mysql/mysql.conf.d/mysqld.cnf
# 2与境、在[mysqld]下吟榴,加入lower_case_table_names=1;
[mysqld]
#
# * Basic Settings
#
lower_case_table_names=1
# 3茫蛹、重啟mysql
sudo service mysql restart
# 4操刀、查詢lower_case_table_names值還是0;
mysql> SHOW VARIABLES LIKE 'lower_case_table_names';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| lower_case_table_names | 0 |
+------------------------+-------+
1 row in set (0.00 sec)
二、問題處理
# 每次進入到mysql的時候婴洼,提示配置文件'/etc/mysql/my.cnf'是可寫的骨坑,因此被忽略了;
root@sawltest:/etc/init.d# mysql -u root -p
mysql: [Warning] World-writable config file '/etc/mysql/my.cnf' is ignored.
# 將文件的權(quán)限更改為600柬采,這樣只有所有者才有讀寫權(quán)限欢唾,其他用戶沒有任何權(quán)限。然后粉捻,您需要將文件的所有者更改為mysql用戶和mysql組礁遣,以確保MySQL服務(wù)器有權(quán)限讀取和使用該文件。
sudo chmod 600 /etc/mysql/my.cnf
sudo chown mysql:mysql /etc/mysql/my.cnf
重新啟動MySQL服務(wù)器肩刃,以確保更改生效祟霍;
sudo service mysql restart
mysql> SHOW VARIABLES LIKE 'lower_case_table_names';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| lower_case_table_names | 1 |
+------------------------+-------+
1 row in set (0.01 sec)