Invalid default value for timestamp field MySQL
Problem Statement: Invalid default value for timestamp field
Some more examples:
Invalid default value for ‘create_date’ timestamp field
Invalid default value for ‘updated_at’ in mysql
Invalid default value for ‘dateAdded’
Solution:
The problem is because of sql_modes. You have to remove the sql_mode to make it work.
You can do this using these 3 methods:
Methods 1:
Remove these SQL modes
NO_ZERO_IN_DATENO_ZERO_DATE
Method 2:
Before you run any query put this query in the first line:
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";SET time_zone = "+00:00";
Method 3:
Before you run any query put this query in the first line:
SET sql_mode = '';