如何在 localhost (xampp) 中打开/关闭 MySQL 严格模式?

2022-01-14 00:00:00 localhost xampp mariadb mysql mariasql

我想知道如何在 localhost(xampp) 中检查 MySQL 严格模式是打开还是关闭.

I want to know how to check whether MySQL strict mode is on or off in localhost(xampp).

如果开启则为哪些模式以及如何关闭.

If on then for what modes and how to off.

如果关闭,那么如何开启.

If off then how to on.

我已经关注了 http:///dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-full 和 https://mariadb.com/kb/en/mariadb/sql_mode/ 和其他相关网站.但是我的问题没有得到确切的答案.

I already followed http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-full and https://mariadb.com/kb/en/mariadb/sql_mode/ and other related sites too. But I didn't get an exact answer for my question.

推荐答案

->STRICT_TRANS_TABLES负责设置MySQL严格模式.

->STRICT_TRANS_TABLES is responsible for setting MySQL strict mode.

->检查是否启用了严格模式,运行以下sql:

->To check whether strict mode is enabled or not run the below sql:

SHOW VARIABLES LIKE 'sql_mode';

如果其中一个值是 STRICT_TRANS_TABLES,则启用严格模式,否则不启用.就我而言,它给了

If one of the value is STRICT_TRANS_TABLES, then strict mode is enabled, else not. In my case it gave

+--------------+------------------------------------------+ 
|Variable_name |Value                                     |
+--------------+------------------------------------------+
|sql_mode      |STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION|
+--------------+------------------------------------------+

因此,在我的情况下,严格模式是启用的,因为其中一个值是 STRICT_TRANS_TABLES.

Hence strict mode is enabled in my case as one of the value is STRICT_TRANS_TABLES.

->要禁用严格模式,请运行以下 sql:

->To disable strict mode run the below sql:

set global sql_mode='';

[或除 STRICT_TRANS_TABLES 之外的任何模式.例如:设置全局 sql_mode='NO_ENGINE_SUBSTITUTION';]

[or any mode except STRICT_TRANS_TABLES. Ex: set global sql_mode='NO_ENGINE_SUBSTITUTION';]

->再次启用严格模式运行以下sql:

->To again enable strict mode run the below sql:

set global sql_mode='STRICT_TRANS_TABLES';

相关文章