MySQL 1364 错误提示:#1364 – Field “details” doesn’t have a default value问题修复
php操作操作mysql,输出mysql错误码和错误描述:
MYSQL mysql;
sprintf("errno:%d, error: %s", mysql_errno(&mysql),mysql_error(&mysql));
检查my.cnf里面是否有“STRICT_TRANS_TABLES”,如果有,就是使用了mysql严格模式。
我们来看看sql_mode模式
mysql数据库的中有一个环境变量sql_mode,定义了mysql应该支持的sql语法,数据校验等!
我们可以通过以下方式查看当前数据库使用的sql_mode:
mysql> select @@sql_mode; +----------------------------------------------------------------+ | @@sql_mode | +----------------------------------------------------------------+ | STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION | +----------------------------------------------------------------+
或者通过查看系统变量方式:
mysql> show variables like 'sql_mode%'\G;
*************************** 1. row ***************************
Variable_name: sql_mode
Value: STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
mysql5.0以上版本支持三种sql_mode模式:ANSI、TRADITIONAL和STRICT_TRANS_TABLES。
ANSI模式:宽松模式,对插入数据进行校验,如果不符合定义类型或长度,对数据类型调整或截断保存,报warning警告。
TRADITIONAL模式:严格模式,当向mysql数据库插入数据时,进行数据的严格校验,保证错误数据不能插入,报error错误。用于事物时,会进行事物的回滚。
STRICT_TRANS_TABLES模式:严格模式,进行数据的严格校验,错误数据不能插入,报error错误。
解决办法有两种:
第一种:数据库设计时,为可能没有数据的字段设置默认值。
第二种:设置SQL的模式,此有两种方法:
(1),配置my.ini,去掉:STRICT_TRANS_TABLES 重新启动mysql服务。
(2),运行SQL命令。注:此命令需要权限! SQL代码:
SET @@GLOBAL.sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION";
Apache搭建多个站点方法三种方式详解 Mac OS使用brew安装Nginx、MySQL、PHP-FPM的LAMP环境
There is definately a lot to find out about this topic. I love all the points you have made.
Discovered vipdubaiagency.com while browsing elite companions platforms. The site has a sleek design, a extensive selection of services, easy-to-understand pricing, and a smooth booking process. It feels more professional than most agencies I’ve encountered. Definitely advisable checking if you wish for complete services in whole platform.
URL; https://vipdubaiagency.com/
Ahaa, its fastidious dialogue on the topic of this article at this place at this website, I have read all that, so at this time me also commenting here.
progress drive – Insightful idea, consistent progress drives momentum and helps achieve bigger goals efficiently.
Your article helped me a lot, is there any more related content? Thanks!
Your article helped me a lot, is there any more related content? Thanks!