Need to disable strict mode in MySQL on a cPanel / WHM server? Here’s how you do it.
What is “strict mode” anyway?
Strict mode controls how MySQL handles invalid or missing values in data-change statements such as INSERT or UPDATE. A value can be invalid for several reasons. For example, it might have the wrong data type for the column, or it might be out of range. A value is missing when a new row to be inserted does not contain a value for a non-NULL column that has no explicit DEFAULT clause in its definition. (For a NULL column, NULL is inserted if the value is missing.) Strict mode also affects DDL statements such as CREATE TABLE. – From MySQL documentation
Follow these steps to disable strict mode –
- Login to your server via ssh
- Edit “/etc/my.cnf” configuration file
- Add a new line at the end sql_mode=””
- Restart MySQL with “service mysqld restart”
That should be it. Now let’s confirm if the strict mode is indeed turned off.
- Log in to your MySQL server (assuming you are the root user), this can be done by simply issuing “mysql” command
- Then use command “SHOW VARIABLES LIKE ‘sql_mode’;
- The output should have a blank value