Question:
How do I determine the status of MySQL strict mode in localhost (XAMPP) and toggle it on or off as needed?
Solution:
Checking the Strict Mode Status:
To check if strict mode is enabled, run the following SQL query:
SHOW VARIABLES LIKE 'sql_mode';
If one of the values returned in the Value column is STRICT_TRANS_TABLES, then strict mode is enabled. Otherwise, it is disabled.
Disabling Strict Mode:
To disable strict mode, execute the following SQL query:
set global sql_mode='';
You can also specify any other SQL mode except STRICT_TRANS_TABLES. For example:
set global sql_mode='NO_ENGINE_SUBSTITUTION';
Enabling Strict Mode:
To re-enable strict mode, run the following SQL query:
set global sql_mode='STRICT_TRANS_TABLES';
Note:
The sql_mode variable can be set globally or for specific connections. The above queries modify the global setting. To set the mode for a specific connection, use the SET sql_mode command.
The above is the detailed content of How to Enable or Disable Strict Mode in MySQL (XAMPP)?. For more information, please follow other related articles on the PHP Chinese website!