gpt4 book ai didi

mysql - SQLSTATE[22007] : Invalid datetime format: 1292 Incorrect datetime value: '2008-03-30 02:56:12'

转载 作者:可可西里 更新时间:2023-11-01 07:49:31 25 4
gpt4 key购买 nike

系统本地 PHP 5.6.19使用 Laravel 5.0 制作的应用程序,使用 fzaninotto/Faker 作为播种器Mysql远程

远程MySQLDebian 8 与 MariaDB 10.1.13-MariaDB-1~jessie

运行播种机

php artisan migrate:reset; php artisan migrate; php artisan db:seed

seeder添加不确定数量的用户后(每次重现报错都不同)报错:

[Illuminate\Database\QueryException]
SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2008-03-30 02:56:12' for column 'created_at' at row 1 (S
QL: insert into `users` (`type`, `name`, `email`, `nick`, `password`, `vat`, `address`, `zipcode`, `city`, `state`, `country`, `cr
eated_at`, `updated_at`) values (customer, Adrian Santos, qpuig@live.com, rzavala12, y$Veqd2mkgRHtl6VKtYBV0yey77tVLo34.6THXqhtGRwg
/Ea73/FhlK, 02058805Y, Plaça Abril, 85, 96º D, 44824, Vargas de San Pedro, 57431, San Roig, Huesca, ES, 2008-03-30 02:56:12, 2008-
03-30 02:56:12))

嗯..日期时间是 2008-03-30 02:56:12

在出现错误之前使用播种机创建的最新 3 个用户的示例:

INSERT INTO `users` (`id`,`type`,`email`,`nick`,`password`,`name`,`vat`,`address`,`zipcode`,`city`,`state`,`country`,`totals`,`remember_token`,`created_at`,`updated_at`) VALUES (15053,'buyer','asauceda@live.com','celia657','$2y$10$P4SOJOAQHsC8W7ctJ5v1F.8loccYzjAW95ILwWZ1RzObNs01hKjr2','Bruno Aguado','71514876X','Paseo Corral, 1, Entre suelo 0º, 63362, La Saiz','58061','Navarrete de Ulla','Cádiz','ES',NULL,NULL,'2012-09-13 06:01:51','2012-09-13 06:01:51');
INSERT INTO `users` (`id`,`type`,`email`,`nick`,`password`,`name`,`vat`,`address`,`zipcode`,`city`,`state`,`country`,`totals`,`remember_token`,`created_at`,`updated_at`) VALUES (15052,'buyer','ana.serna@live.com','cristian126','$2y$10$fe2Hdh4p0bttNfo9uzwSe.L5OOzPwsm5p8g5.YhW5PAoxKcSObDta','Enrique Rivero','06604287K','Ronda Saul, 321, 8º C, 76264, San Álvarez de Arriba','11402','El Roybal Baja','Zamora','ES',NULL,NULL,'2007-11-14 16:39:41','2007-11-14 16:39:41');
INSERT INTO `users` (`id`,`type`,`email`,`nick`,`password`,`name`,`vat`,`address`,`zipcode`,`city`,`state`,`country`,`totals`,`remember_token`,`created_at`,`updated_at`) VALUES (15051,'buyer','iluna@terra.com','aalmanza21','$2y$10$EA.NhWHuT8.nGoZjD18hqOKatHH3MbboY2DjZywlceH8K60spAe5m','Miriam Riojas','24055470T','Calle Soriano, 0, 75º A, 29744, L\' Montenegro','12236','As Martínez','Illes Balears','ES',NULL,NULL,'2013-03-25 23:15:50','2013-03-25 23:15:50');
INSERT INTO `users` (`id`,`type`,`email`,`nick`,`password`,`name`,`vat`,`address`,`zipcode`,`city`,`state`,`country`,`totals`,`remember_token`,`created_at`,`updated_at`) VALUES (15050,'buyer','qsalgado@hotmail.com','mateo26','$2y$10$6.lFRsqEjXb1kdZOhAX7Cu1Xecgu1ZvAkhaADKcfSpEi6ODQM9nRK','Alonso Núñez','50161945A','Camino Ainara, 78, 65º A, 17155, L\' Ayala del Pozo','47226','Román de las Torres','Las Palmas','ES',NULL,NULL,'2016-05-12 11:00:01','2016-05-12 11:00:01');

阅读一些资料,比如MYSQL incorrect DATETIME format , How to make sql-mode=“NO_ENGINE_SUBSTITUTION” permanent in MySQL my.cnf并验证此问题的 mysql 变量。

MariaDB [(none)]> select @@GLOBAL.sql_mode;
--------------
select @@GLOBAL.sql_mode
--------------

+------------------------+
| @@GLOBAL.sql_mode |
+------------------------+
| NO_ENGINE_SUBSTITUTION |
+------------------------+
MariaDB [(none)]> select @@SESSION.sql_mode;
--------------
select @@SESSION.sql_mode
--------------

+------------------------+
| @@SESSION.sql_mode |
+------------------------+
| NO_ENGINE_SUBSTITUTION |
+------------------------+
1 row in set (0.00 sec)

最佳答案

问题很简单。这是关于“夏令时”的问题

通过查阅 Daylight Saving Time Spain 的表格,而那个日期确实是 27/03/2011 下午 02:00。因此,任何日期都是包含时间的一天,在 02:00 和 02:59 之间将失败,因为时钟从 02:00 向前移动到 02:59。

关于mysql - SQLSTATE[22007] : Invalid datetime format: 1292 Incorrect datetime value: '2008-03-30 02:56:12' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37203899/

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