Home  >  Article  >  Database  >  How to Check, Enable, and Disable Strict Mode in MySQL (XAMPP)?

How to Check, Enable, and Disable Strict Mode in MySQL (XAMPP)?

Patricia Arquette
Patricia ArquetteOriginal
2024-10-26 21:53:03466browse

How to Check, Enable, and Disable Strict Mode in MySQL (XAMPP)?

Understanding MySQL Strict Mode in Localhost (XAMPP)

MySQL strict mode enforces data integrity by rejecting queries that do not conform to certain rules. In XAMPP, checking the status of strict mode and modifying its settings are essential for ensuring data accuracy.

Checking Strict Mode Status

To determine if strict mode is enabled in your localhost XAMPP setup, run the following SQL command:

<code class="sql">SHOW VARIABLES LIKE 'sql_mode';</code>

If the output includes the value STRICT_TRANS_TABLES, then strict mode is enabled.

Disabling Strict Mode

To disable strict mode, execute the following SQL command:

<code class="sql">SET GLOBAL sql_mode='';</code>

Alternatively, you can specify any mode other than STRICT_TRANS_TABLES, such as:

<code class="sql">SET GLOBAL sql_mode='NO_ENGINE_SUBSTITUTION';</code>

Enabling Strict Mode

To re-enable strict mode, run the following SQL command:

<code class="sql">SET GLOBAL sql_mode='STRICT_TRANS_TABLES';</code>

By adjusting the sql_mode variable, you can ensure that MySQL enforces data integrity rules as per your requirements.

The above is the detailed content of How to Check, Enable, and Disable Strict Mode in MySQL (XAMPP)?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn