SOLVED should i disable strict mode?

uk01

Well-Known Member
Dec 31, 2009
232
35
78
Hi we've had a request from a customer to disable mysql strict mode on their account.

It seems this is not possible through php.ini?

The only way we can disable is for everyone via my.cnf... is this a safe thing to do and would it affect other databases or cause corruption?

Is it recommended? We use mariadb
 

ffeingol

Well-Known Member
PartnerNOC
Nov 9, 2001
940
420
363
cPanel Access Level
DataCenter Provider
You are correct that it can only be done via my.cnf (as it's a MySQL setting not a PHP setting).

It won't cause corruption, but turning it off is more of a band-aid than anything else. As an example: Let's say you have a table that has a char(10) column (that is a column that holds up to 10 characters). With strict mode off if they try to put 11 characters in the column MySQL will simply truncate the 11th character and move on. With strict mode on they will get a SQL error, since it can't store the data.

There are other scenarios, but it all basically boils down to poor/sloppy coding. All modern open source software has no issues with strict. What we've come across is one-off / hand coded sites.

Hopefully that helps a bit.
 

uk01

Well-Known Member
Dec 31, 2009
232
35
78
Thank you that helps alot and I appreciate your reply.

We will refuse the request on the cpanel platform.

They also have a vps so I will advise them to install mysql there and connect remotely to that database.