简体   繁体   English

MySQL的:不能设置lower_case_table_names变量

[英]Mysql : can't set lower_case_table_names variable

I'm installing new software on a new Ubuntu 16.0.4 machine and installed MySQL with apt-get. 我正在新的Ubuntu 16.0.4计算机上安装新软件,并使用apt-get安装了MySQL。 The version I get is 5.7.22 but can't get it to accept my settings of the configuration variable lower_case_table_names. 我得到的版本是5.7.22,但是无法接受我对配置变量lower_case_table_names的设置。

I'm adding lines like: 我要添加如下行:

[mysql]
lower_case_table_names = 1

When I edit any of the *.cnf files in /etc/mysql to have this setting or if I add it to ~/.my.cnf I get 当我在/ etc / mysql中编辑任何* .cnf文件以具有此设置时,或者如果将其添加到〜/ .my.cnf中,我都会得到

mysql: [ERROR] unknown variable 'lower_case_table_names=1'

if I try to start mysql. 如果我尝试启动mysql。 Similarly I can't use it on the mysql command line like the doc says I can. 同样,我不能像doc所说的那样在mysql命令行上使用它。

/usr/bin/mysql --lower_case_table_names=1 -u root -p

However: 然而:

If I go into the SQL command interpreter and type 如果我进入SQL命令解释器并输入

mysql> select @@lower_case_table_names;

I get back a result showing the variable is set to 0. However it cannot be changed with a SET statement... 我得到一个显示该变量设置为0的结果。但是不能使用SET语句更改它。

So whats the deal with why I can't set this variable ? 那么为什么不能设置此变量呢?

~/.my.cnf file: 〜/ .my.cnf文件:

[mysqld]
lower_case_table_names = 1
[mysql]
lower_case_table_names = 1

Why is mysql not liking this variable name when clearly it still has a setting for it? 为什么mysql显然仍然有它的设置时不喜欢这个变量名?

The problem is that this variable does not apply to mysql. 问题是该变量不适用于mysql。 It only applies to mysqld. 它仅适用于mysqld。 Stop mysqld, change the my.cnf to have a setting for [mysqld], and then start mysqld. 停止mysqld,将my.cnf更改为具有[mysqld]的设置,然后启动mysqld。 This will set the lower_case_table_names value for the mysql server. 这将设置mysql服务器的lower_case_table_names值。

If you run /usr/bin/mysql (a command line mysql shell) it will not want a setting for this var in the config file. 如果运行/ usr / bin / mysql(命令行mysql shell),则它不需要在配置文件中为此var进行设置。 The shell will behave as the mysql server behaves. Shell的行为将与mysql服务器的行为相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM