1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > mysql 开启不严谨模式 mysql – 为什么innodb严格模式无法启用?

mysql 开启不严谨模式 mysql – 为什么innodb严格模式无法启用?

时间:2021-10-16 04:22:53

相关推荐

mysql 开启不严谨模式 mysql  – 为什么innodb严格模式无法启用?

我试过在/etc/mysql/mysql.conf.d/f(Ubuntu)中添加这一行

innodb_strict_mode = 1

这是在[mysqld]部分,我在其他示例中看到过这一行.我知道这个配置文件正在启动时读取,因为如果我输入废话我会收到错误.

尽管如此,SHOW VARIABLES将此变量列为OFF,显然我可以在不指定非默认字段的情况下插入行.

为什么不设置此变量?

我试过= on而不是= 1,没有区别.否则,配置将从安装默认值AFAIK,全文here中修改.

解决方法:

您可以从命令行设置此SESSION变量:

mysql> show variables like '%strict%';

+--------------------+-------+

| Variable_name | Value |

+--------------------+-------+

| innodb_strict_mode | OFF |

+--------------------+-------+

1 row in set (0.01 sec)

然后,你这样做:

mysql> set innodb_strict_mode = ON;

Query OK, 0 rows affected (0.00 sec)

然后,检查:

mysql> show variables like '%strict%';

+--------------------+-------+

| Variable_name | Value |

+--------------------+-------+

| innodb_strict_mode | ON |

+--------------------+-------+

然后,在退出并重新连接并重新检查变量时,它再次为OFF – 默认值.如果您不想在注销后重置,请使用SET GLOBAL innodb_strict_mode = ON.但是,在重新启动服务器后,在客户端中设置它不会使更改成为可能.

编辑f – 我从未见过或触及过f.

将下面的行放在f的[mysqld]部分中.

sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY"

innodb_strict_mode = ON

(我也建议使用sql_mode行 – 否则,例如,某些GROUP BY查询将返回(ahem …)异常结果).

弹回服务器 – 然后重新登录.

mysql> show variables like '%strict%';

+--------------------+-------+

| Variable_name | Value |

+--------------------+-------+

| innodb_strict_mode | ON |

+--------------------+-------+

1 row in set (0.01 sec)

这些都在文档here中.

You can turn innodb_strict_mode ON or OFF on the command line when you

start mysqld, or in the configuration file f or my.ini. You can

also enable or disable innodb_strict_mode at runtime with the

statement SET [GLOBAL|SESSION] innodb_strict_mode=mode, where mode is

either ON or OFF. Changing the GLOBAL setting requires the SUPER

privilege and affects the operation of all clients that subsequently

connect. Any client can change the SESSION setting for

innodb_strict_mode, and the setting affects only that client.

也许你没有SUPER特权?登录并运行SHOW GRANTS以查找.

标签:mysql

来源: https://codeday.me/bug/0806/1600632.html

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。