Disable MySQL Strict Mode In MySQL and MariaDB
If you have recently installed MySQL on your server it’s likely MySQL Strict Mode is enabled. Since MySQL version 5.7, it was enabled by default. Strict Mode stipulates how your database server will handle invalid requests in code. In previous versions, MySQL would ignore these values as much as possible. This affects the following MySQL and MariaDB versions
- MySQL 5.7
- MySQL 8.0
- Maria DB 10.3
- MariaDB 10.4
- MariaDB 10.5
The Problem With Strict Mode
Enabling strict mode in MySQL means if you have an outdated script or a script that was using previously valid syntax your program or script will cease working. This has caused many problems for users. So, by having this mode enabled for new installs and upgrades. Programs that run fine previously ceased to work until strict mode was disabled.
However, MySQL can be set to operate in different SQL modes and these modes can be set on a per-server or per-client basis. In this guide, we will disable Strict Mode server-wide.
Note- New installs of cPanel now automatically disable strict mode.
Disable MySQL Strict Mode
Log in as the root user to your server and find you’re my.cnf file for MySQL, it’s usually located at /etc/my.cnf. At the bottom of this file place the below code and save the document.
sql_mode=""
Now, restart your MySQL server and strict mode will be disabled. There are some security concerns when disabling strict mode and you should check with your developer that any programs you run are secure. Whilst strict mode is inconvenient for many users it also does serve a purpose.