[英]sql_mode not updating, even though I've changed it in my.cnf
I'm trying to tweak a database that we moved from a mySQL 5.5 server, to a 5.7 server. 我正在尝试调整从mySQL 5.5服务器移至5.7服务器的数据库。 It's complaining about the date being 0000-00-00
format. 它抱怨日期为0000-00-00
格式。 I'm trying to fix this, but I can't get past the errors. 我正在尝试解决此问题,但我无法克服这些错误。
In my.cnf , I have: 在my.cnf中 ,我有:
sql_mode=ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,TRADITIONAL,ALLOW_INVALID_DATES
I restart mySQL, and then do this in phpmyadmin: 我重新启动mySQL,然后在phpmyadmin中执行以下操作:
SHOW VARIABLES LIKE 'sql_mode'
But it shows a totally wrong/different list! 但是它显示了完全错误/不同的列表!
sql_mode
STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ALLOW_INVALID_DATES,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
What am I doing wrong? 我究竟做错了什么? This is driving me nuts! 这真让我发疯!
According to the manual , TRADITIONAL
includes several other modes: 根据手册 , TRADITIONAL
包括其他几种模式:
TRADITIONAL 传统的
Before MySQL 5.7.4, and in MySQL 5.7.8 and later,
TRADITIONAL
is equivalent toSTRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER
, andNO_ENGINE_SUBSTITUTION
. 在MySQL 5.7.4之前和MySQL 5.7.8及更高版本中,TRADITIONAL
等效于STRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER
和NO_ENGINE_SUBSTITUTION
。From MySQL 5.7.4 though 5.7.7,
TRADITIONAL
is equivalent toSTRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_AUTO_CREATE_USER
, andNO_ENGINE_SUBSTITUTION
. 从MySQL 5.7.4到5.7.7,TRADITIONAL
等效于STRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_AUTO_CREATE_USER
和NO_ENGINE_SUBSTITUTION
。 TheNO_ZERO_IN_DATE, NO_ZERO_DATE
, andERROR_FOR_DIVISION_BY_ZERO
modes are not named because in those versions their effects are included in the effects of strict SQL mode (STRICT_ALL_TABLES
orSTRICT_TRANS_TABLES
). 未命名NO_ZERO_IN_DATE, NO_ZERO_DATE
和ERROR_FOR_DIVISION_BY_ZERO
模式,因为在这些版本中,它们的效果包括在严格的SQL模式的效果(STRICT_ALL_TABLES
或STRICT_TRANS_TABLES
)中。 Thus, the effects ofTRADITIONAL
are the same in all MySQL 5.7 versions (and the same as in MySQL 5.6). 因此,在所有MySQL 5.7版本中,TRADITIONAL
的效果都相同(与MySQL 5.6中的效果相同)。 For additional discussion, see SQL Mode Changes in MySQL 5.7. 有关其他讨论,请参见MySQL 5.7中的SQL模式更改。
So the expansion of the mode is expected and your two modes are equivalent for MySQL 5.7.8+. 因此,期望该模式的扩展,并且您的两种模式对于MySQL 5.7.8+是等效的。 The sql mode setting is actually evaluated: you can see eg that your final mode includes the non-default ALLOW_INVALID_DATES
, as defined in your configuration file. 实际上,对sql模式设置进行了评估:例如,您可以看到最终模式包括配置文件中定义的非默认ALLOW_INVALID_DATES
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.