#1067 - Invalid default value for 'created_date'

imabotmail

Well-known member
Trusted Uploader
Jan 17, 2020
338
302
63
I'm trying to run the following query into mysql via phpmyadmin and I keep getting this error and I don't know know how to solve it.

Spoiler

I've tried to everything listed here: Google Search and nothing works. What am I doing wrong? Any mysql expert here, please help.
 

jackdanielz

New member
May 5, 2022
24
11
3
I'm trying to run the following query into mysql via phpmyadmin and I keep getting this error and I don't know know how to solve it.

Spoiler

I've tried to everything listed here: Google Search and nothing works. What am I doing wrong? Any mysql expert here, please help.

If you replace the following two lines, it should work.

`created_date` datetime DEFAULT NOT NULL CURRENT_TIMESTAMP,
`updated_date` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

or

`created_date` datetime DEFAULT NOT NULL CURRENT_TIMESTAMP,
`updated_date` datetime DEFAULT NOW()
 

imabotmail

Well-known member
Trusted Uploader
Jan 17, 2020
338
302
63
I get this:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NOT NULL CURRENT_TIMESTAMP,
`updated_date` datetime DEFAULT CURRENT_TIMESTAMP' at line 17
 

jackdanielz

New member
May 5, 2022
24
11
3
I get this:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NOT NULL CURRENT_TIMESTAMP,
`updated_date` datetime DEFAULT CURRENT_TIMESTAMP' at line 17

`created_date` DATETIME DEFAULT CURRENT_TIMESTAMP NOT NUll,
`updated_date` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

or

`created_date` datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
`updated_date` datetime DEFAULT NOW()

Sorry, I guess I need a coffee.. ;)
 
Last edited:

imabotmail

Well-known member
Trusted Uploader
Jan 17, 2020
338
302
63
😂 I hear you. Brewing a fresh pot as we speak. LOL Sorry, neither one work. :(
A little insight, I'm running Plesk CP with mysql 5.5.68-MariaDB and can't upgrade either.
 

jackdanielz

New member
May 5, 2022
24
11
3
😂 I hear you. Brewing a fresh pot as we speak. LOL Sorry, neither one work. :(
A little insight, I'm running Plesk CP with mysql 5.5.68-MariaDB and can't upgrade either.
Oh dear... this is an old version of mysql, it is not implemented there yet.

Try the following:
`created_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_date` timestamp NOT NULL DEFAULT ' 0000-00-00 00:00:00 '
 

imabotmail

Well-known member
Trusted Uploader
Jan 17, 2020
338
302
63
Nope, but different error: #1005 - Can't create table 'scmdb.online_courses' (errno: 150)
 

jackdanielz

New member
May 5, 2022
24
11
3
Nope, but different error: #1005 - Can't create table 'scmdb.online_courses' (errno: 150)
It could be the "Foreign Key"... Add it before and after your query.

SET FOREIGN_KEY_CHECKS = 0;
CREATE TABLE `online_courses` (
...
`created_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_date` timestamp NOT NULL DEFAULT NOW()
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
SET FOREIGN_KEY_CHECKS = 1;

If that doesn't work, I'm afraid I'm out. :)
 
  • Like
Reactions: TassieNZ

imabotmail

Well-known member
Trusted Uploader
Jan 17, 2020
338
302
63
Thank you my friend @jackdanielz - I too, I'm giving up. Sadly this gives the following error. Thanks for all your help.

#1005 - Can't create table 'scmdb.online_courses' (errno: 150)
 

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu