
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Disable Strict Mode in MySQL
The handling of missing or incorrect values in queries that change the data is governed by MySQL Strict Mode. This contains the CREATE TABLE, UPDATE, and INSERT statements. When attempting to process the query with MySQL Strict Mode enabled, which is the default setting, invalid or missing data may result in warnings or failures.
When Strict Mode is turned off, the identical query would have its missing or incorrect data modified and would result in a straightforward warning. This could appear to be the desired outcome, but with Strict Mode turned off, certain activities might have unanticipated effects. For instance, if a value is being added and it has more characters than the allowed number, it will be truncated to fit.
The strict mode for MySQL is always on. It can be disabled in a few different ways.
To Disable Strict Mode via SQL
The following command can be performed to disable strict mode on your MySQL server using this way.
mysql -u root -p -e "SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION';"
Now, you can verify that the mode is set by running the following ?
mysql -u root -p -e "SELECT @@GLOBAL.sql_mode;"
Disable Strict Mode via my.cnf/my.ini:
To edit, launch the my.ini or my.cnf file (the file you have depends on whether you are running Windows or Linux).
Find the following line
sql_mode = "STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
-
Change it to the following line:
Insert the line under the [mysqld] section if it cannot be found (if there is no [mysqld] section, create it).
Create mysqlId in the following way: sql_mode= ""
-
To make the modification effective, restart the MySQL service.
If restarting is not an option right now, you can get into the database server and use the command listed below to make the changes effective right away. If the aforementioned procedure is not carried out, the modification is lost the next time the MySQL service restarts.
set global sql_mode='';
No matter why a MySQL administrator has to disable Strict Mode, doing so is a simple process. You may disable MySQL Strict Mode on servers using this approach.
This rule applies to Standard Edition, Standard (Multi-Language) Edition, Enterprise Edition (MySQL), Enterprise Multi-Language Edition (MySQL), Enterprise Edition (SQL Server), and Enterprise Edition (MySQL) (SQL Server)