I have the following sql create statement
mysql> CREATE TABLE IF NOT EXISTS `erp`.`je_menus` (
-> `id` INT(11) NOT NULL AUTO_INCREMENT ,
-&g
Just Define following lines at top of your Database SQL file.
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
It is working for me.
Change this:
`create_date` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
`update_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
To the following:
`create_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
`update_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
To avoid this issue, you need to remove NO_ZERO_DATE
from the mysql mode configuration.
NO_ZERO_DATE
(and its trailing comma) from the configuration.This is a very common issue in the local environment with wamp or xamp.
You might like to examine the timezone setting on the MySql instance:
mysql> show variables like 'time_zone';
+---------------+--------+
| Variable_name | Value |
+---------------+--------+
| time_zone | SYSTEM |
+---------------+--------+
in my case, I realised that the underlying system had it's timezone set to BST rather than UTC, and so in the create table the default of '1970-01-01 00:00:01' was being coerced back 1 hour, resulting in an invalid timestamp value.
For me, I actually wanted the machine's timezone set to UTC, and that sorted me out. As I was running Centos/7, I simply did
# timedatectl set-timezone UTC
and restarted everything.
You could just change this:
create_date
datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
To something like this:
create_date
varchar(80) NOT NULL DEFAULT '0000-00-00 00:00:00',
To disable strict SQL mode
Create disable_strict_mode.cnf file at /etc/mysql/conf.d/
In the file, enter these two lines:
[mysqld]
sql_mode=IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Finally, restart MySQL with this command:
sudo service mysql restart