I have the following sql create statement
mysql> CREATE TABLE IF NOT EXISTS `erp`.`je_menus` (
-> `id` INT(11) NOT NULL AUTO_INCREMENT ,
-&g
I was able to resolve this issue on OS X by installing MySQL from Homebrew
brew install mysql
by adding the following to /usr/local/etc/my.cnf
sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
and restarting MySQL
brew tap homebrew/services
brew services restart mysql
I try to set type of column as 'timestamp' and it works for me.
If you generated the script from the MySQL workbench.
The following line is generated
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
Remove TRADITIONAL from the SQL_MODE, and then the script should work fine
Else, you could set the SQL_MODE as Allow Invalid Dates
SET SQL_MODE='ALLOW_INVALID_DATES';
TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC (see doc). The default value must be within that range.
Other odd, related, behavior:
CREATE TABLE tbl1 (
ts TIMESTAMP);
Query OK, 0 rows affected (0.01 sec)
CREATE TABLE tbl2 (
ts TIMESTAMP,
ts2 TIMESTAMP);
ERROR 1067 (42000): Invalid default value for 'ts2'
CREATE TABLE tbl3 (
ts TIMESTAMP,
ts2 TIMESTAMP DEFAULT '1970-01-01 00:00:01');
Query OK, 0 rows affected (0.01 sec)
Side note, if you want to insert NULLS:
CREATE TABLE tbl4 (
ts TIMESTAMP NULL DEFAULT NULL);