gpt4 book ai didi

php - 字段 'password' 没有默认值

转载 作者:行者123 更新时间:2023-11-28 23:57:38 27 4
gpt4 key购买 nike

Laravel 在 Facebook 登录时出错,并显示以下消息:

General error: 1364 Field 'password' doesn't have a default value

如果我将 mysql db col 设置为允许 NULL 和默认 NULL,它工作正常。

与脚本相同的数据库在多台其他机器上工作正常。为什么?我的mysql安装有什么问题? (不同机器上的mysql版本相同,ubuntu mysql正常,mac mysql失败,mac上的多个homestead mysql也正常)

CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
`remember_token` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`code` int(11) NOT NULL,
`activate` int(11) NOT NULL DEFAULT '0',
`avatar` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`phone` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`address` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`website` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`search_points` int(11) NOT NULL DEFAULT '0',
`sms_code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`sms_verify` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `users_email_unique` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

最佳答案

很可能,您的其他服务器被(错误)配置为将 NULL 值转换为空字符串,而该其他服务器被配置为使用 strict mode :

Strict mode controls how MySQL handles invalid or missing values in data-change statements such as INSERT or UPDATE. A value can be invalid for several reasons. For example, it might have the wrong data type for the column, or it might be out of range. A value is missing when a new row to be inserted does not contain a value for a non-NULL column that has no explicit DEFAULT clause in its definition. (For a NULL column, NULL is inserted if the value is missing.)

正确的解决方法确实是您提到的那个:如果该列不是强制性的,那么它首先不应该是 NOT NULL

关于php - 字段 'password' 没有默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31144122/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com