MySQL 1364 错误提示:#1364 - Field "details" doesn't have a default value。大概意思是:details字段没有默认的数值;也就是说我们没有为其分配数值,而表中此字段也没有设置默认值。这是MySQL5出来后搞出来的东东,认真看一下my.ini文件中有这样一段:
MySQL 1364 错误提示:#1364 - Field "details" doesn't have a default value。大概意思是:details字段没有默认的数值;也就是说我们没有为其分配数值,而表中此字段也没有设置默认值。这是MySQL5出来后搞出来的东东,认真看一下my.ini文件中有这样一段:
my.ini中相关代码
- # Set the SQL mode to strict
- # sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
- sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
假如您无法看到my.ini,你可以执行以下SQL命令。
SQL代码
- SELECT @@GLOBAL.sql_mode;
您可能一下子就注意到:STRICT_TRANS_TABLES(存储引擎启用严格模式,非法数据值被拒绝)。这也就是为什么我们插入数据时返回1364的原因:details字段没有设置默认值。
解决办法有两种:
第一种:数据库设计时,为可能没有数据的字段设置默认值。
第二种:设置SQL的模式,此有两种方法:
(1),配置my.ini,去掉:STRICT_TRANS_TABLES
my.ini配置代码
- # Set the SQL mode to strict
- # sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
- sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
(2),运行SQL命令。注:此命令需要权限!
SQL代码
- SET @@GLOBAL.sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION";

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools
