Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kaorukobo/718f4eb684ac01e1b65fc4cb69587fae to your computer and use it in GitHub Desktop.
Save kaorukobo/718f4eb684ac01e1b65fc4cb69587fae to your computer and use it in GitHub Desktop.
How to solve the `invalid default value for 'post_date'` error on WordPress DB with MySQL when modifying the schema of wp_posts table
SET SQL_MODE = '';
ALTER TABLE `wp_posts` CHANGE `post_date` `post_date` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00';
ALTER TABLE `wp_posts` CHANGE `post_date_gmt` `post_date_gmt` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00';
ALTER TABLE `wp_posts` CHANGE `post_modified` `post_modified` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00';
ALTER TABLE `wp_posts` CHANGE `post_modified_gmt` `post_modified_gmt` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00';
@pwastack
Copy link

pwastack commented Apr 6, 2024

great thanks, this save me hours!

@arctic-blue
Copy link

wonderfull! Thanks a lot!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment