If you try to alter wp_users
with MySQL 5.7.5+ you'll get the following error:
Invalid default value for 'user_registered'
This is because the NO_ZERO_DATE
mode was added as default in MySQL 5.7.5 which forbids the date 0000-00-00
. WordPress sets the default value for user_registered
to 0000-00-00 00:00:00
, thus this error.
I'm not sure what the best solution is, but because changing user IDs is pretty hacky in the first place this was my quick fix.
I queried the default (session) sql_mode
:
SELECT @@SESSION.sql_mode;
(for me on 5.7.28 this was ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
)
I removed NO_ZERO_IN_DATE
and NO_ZERO_DATE
from this, and then set sql_mode
to it before altering the table:
SET SESSION sql_mode = '(mode string from above without NO_ZERO_DATE)';
ALTER TABLE `wp_users` AUTO_INCREMENT = 2;