MySQL on Cpanel fix: Field 'xxxx' doesn't have a default value

If you are seeing an error in your PHP pages which says something like "MySQL fix: Field 'xxxx' doesn't have a default value", then here is the easy fix.

WHY IS THIS ERROR CAUSED?
This is caused by MySQL having a strict mode set which won't allow INSERT or UPDATE commands with empty fields where the schema doesn't have a default value set.

There are two fixes for this issue. This page shows you the easy global fix.

HOW TO FIX

1. Open up terminal
2. You will need to edit the MySQL config file, so in command line type:

pico /etc/my.cnf



3. This will open up the my.cnf file.

4. Comment out the section called sql_mode (or simply add it if it does not exist)



5. Save, close and restart mysql.

 /scripts/restartsrv mysql

JOB DONE!

You should now be able to use your database as normal now.


  • mysql, INSERT, UPDATE, pico, cpanel
  • 3 Users Found This Useful
Was this answer helpful?