简体   繁体   English

我的 SQl 说 #1067 - 'user_registered' 的默认值无效

[英]My SQl Said #1067 - Invalid default value for 'user_registered'

Table structure for table wpvd_userswpvd_users的表结构

CREATE TABLE `wpvd_users` (  `ID` bigint(20) UNSIGNED NOT NULL,  
`user_login` varchar(60) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',  `user_pass` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',  `user_nicename` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',  `user_email` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',  `user_url` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`user_registered` datetime NOT NULL DEFAULT current_timestamp(),  `user_activation_key` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',  
`user_status` int(11) NOT NULL DEFAULT 0,  
`display_name` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '') 
ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

The problem is because of sql_modes.问题是因为 sql_modes。 Please check your current sql_modes by command:请通过命令检查您当前的 sql_modes:

show variables like 'sql_mode' ; 

And remove the sql_mode "NO_ZERO_IN_DATE,NO_ZERO_DATE" to make it work.并删除 sql_mode "NO_ZERO_IN_DATE,NO_ZERO_DATE" 使其工作。 This is the default sql_mode in mysql new versions.这是 mysql 新版本中默认的 sql_mode。

You can set sql_mode globally as root by command:您可以通过以下命令将 sql_mode 全局设置为 root:

set global sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM