How to solve and fix “Invalid default value” MySQL error for dates and timestamp?

Last updated: 20211220

To avoid this issue, you need to remove NO_ZERO_DATE from the mysql mode configuration.

  1. Go to ‘phpmyadmin’. (in WHM not cPanel)
  2. Once phpmyadmin is loaded up, click on the ‘variables’ tab.
  3. Scroll down and search for ‘sql mode’.
  4. Click on the Edit option and remove NO_ZERO_DATE (and its trailing comma) from the configuration line.
  5. Save (hit ‘save’ on the left side) and that’s it!
  6. You will have to repeat this on every server upgrade/reboot of your MYSQL.

This is a very common issue in the local environment with wamp or xamp.

This will allow you to use default ” 0000-00-00 00:00:00″ as a timestamp value.

Reference:

https://stackoverflow.com/questions/9192027/invalid-default-value-for-create-date-timestamp-field

Leave a Reply

Your email address will not be published. Required fields are marked *