gpt4 book ai didi

mysql - 如何摆脱 MySQL 中的 STRICT SQL 模式

转载 作者:IT老高 更新时间:2023-10-28 23:46:17 26 4
gpt4 key购买 nike

这是对这个问题的跟进 MYSQL incorrect DATETIME format

如何一劳永逸地摆脱 STRICT_TRANS_TABLES?

mysql --help 报告以下配置:

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf

$ ls /etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf
ls: /Users/pain/.my.cnf: No such file or directory
ls: /etc/mysql/my.cnf: No such file or directory
ls: /usr/local/etc/my.cnf: No such file or directory
/etc/my.cnf

$ cat /etc/my.cnf
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION

但这无济于事。我有一些遗留代码,每次重新启动计算机时,我都必须启动 mysql 并更改 sql_mode。

更新

所以我放弃了 Homebrew 安装的 MySQL,并从 mysql.com 下载了它。但这也无济于事。按照这里的答案:How to fix `unknown variable 'sql-mode=ANSI'`?我尝试了 /etc/my.cnf 的不同变体:[mysql][mysqld]sql_mode , sql-mode – 没有任何帮助。

最佳答案

这个问题也困扰了我一段时间。到目前为止,没有一个答案解决了最初的问题,但我相信我的解决了,所以我会发布它以防它对其他人有帮助。

我在 OS X 10.10.3 上安装了 MySQL(来自 mysql.com)Community Edition 5.7.10

最后我创建了一个/etc/mysql/my.cnf,内容如下:-

[mysqld]

sql_mode=NO_ENGINE_SUBSTITUTION

重启服务器后 SHOW VARIABLES LIKE 'sql_mode'; 给了我:-

+---------------+------------------------+
| Variable_name | Value |
+---------------+------------------------+
| sql_mode | NO_ENGINE_SUBSTITUTION |
+---------------+------------------------+
1 row in set (0.00 sec)

最后,没有严格模式!

关于mysql - 如何摆脱 MySQL 中的 STRICT SQL 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18762308/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com