Home Database Mysql Tutorial MySQL之Field‘***’doesn’t have a default value错误解决办法_MySQL

MySQL之Field‘***’doesn’t have a default value错误解决办法_MySQL

Jun 01, 2016 pm 01:00 PM
default

今天,中国博客联盟有博友反馈,zgboke.com无法提交博客,当时我正好准备去假日广场聚会,就匆匆忙忙的提交试了下,发现提交博客的时候确实报如下错误:

提示web_pic不能为空值。很纳闷,之前都可以成功提交的,为什么突然不行了?看了下网上的案例,说是需要修改MySQL的配置什么的,但是目前博客联盟是挂在京东云擎的,数据库不能修改配置,按理说之前可以正常提交,后面应该也可以才对啊!

由于聚会时间快到了,就先放在一边了。回到家之后,对比了下网上的类似案例,原来是web_pic这个键值设置了不为空导致的,也就是在创建表的时候,使用了not null属性。于是进入mywebsql,登入京东云擎数据库,进行了如下操作:

提交后,发现可以成功提交了!出现这个错误的愿意,应该是我最近导入导出数据库太频繁,create tables语句出现错误导致的。

下面,整理一下网上的相同问题的其他解决办法,方便出现问题的同学参考:

1、打开my.ini,查找

sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

修改为

sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

然后重启MYSQL

2、MySQL 5 uses a strict mode which needs to be disabled.

In Windows, Goto Start-->Programs-->MySQL->MySQL Instance Config Wizard. Follow through the Reconfigure Instance option-->Detailed Configuration-->Continue Next a few screens. At the bottom under Enable TCP/IP option there is 'Enable Strict Mode'. Deslect this option (no tick). Save changes and MySQL will restart.

3、看看你的数据库定义的时候是不是把主键生成方式设置为int的,但是没有设置为自增的!!或者数据定义的时候设置一个默认值就可以了。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to configure default gateway How to configure default gateway Dec 07, 2023 am 11:34 AM

Steps to configure default gateway: 1. Determine the IP address of the router; 2. Open the network configuration interface of the computer; 3. Configure network connection; 4. Configure IPv4 settings; 5. Enter the IP address and subnet mask; 6. Configure the default gateway ;7. Configure DNS server; 8. Save settings. Detailed introduction: 1. Determine the router's IP address. The default gateway address is usually the router's IP address. You can find the router's IP address on the back of the router or in the user manual; 2. Open the computer's network configuration, etc.

Configure default gateway Configure default gateway Dec 07, 2023 pm 03:02 PM

Steps to configure default gateway: 1. Open the control panel; 2. Select Network and Internet; 3. Configure network connection; 4. Configure IP address; 5. Configure DNS server address; 6. Confirm the configuration; 7. Restart the network device. Detailed introduction: 1. Open the Control Panel, in Windows system, click the Start menu, select "Control Panel"; 2. Select Network and Internet, in the Control Panel, select "Network and Internet"; 3. Configure network connections, etc. .

An in-depth analysis of the default usage of PHP: revealing its secrets for you An in-depth analysis of the default usage of PHP: revealing its secrets for you Mar 23, 2024 am 08:06 AM

PHP is a scripting language widely used in the field of web development. Developers have benefited a lot from its flexibility and powerful functions. In PHP, setting default values ​​is a common operation, and the default keyword plays a crucial role. This article will deeply analyze the usage of default in PHP, reveal its secrets for you, and combine it with specific code examples to help readers better understand. 1. Default parameter values ​​In PHP, we can set default values ​​for the parameters of a function to prevent

How to configure default gateway How to configure default gateway Dec 07, 2023 pm 02:56 PM

Steps to configure default gateway: 1. Understand the network environment; 2. Obtain the router IP address; 3. Log in to the router management interface; 4. Find and configure the WAN port settings; 5. Configure the default gateway; 6. Save the settings and exit; 7. Check whether the network connection is normal. Configuring the default gateway is an important step in network setup. It determines which router the host uses to access the Internet.

Does the Java keyword contain 'default'? Does the Java keyword contain 'default'? Apr 23, 2023 pm 01:13 PM

Is default a java keyword? Answer: default is a keyword in java8, also called "virtualextensionmethods". The Chinese translation is called "virtual extension method", which contains some default usage methods in the interface. When the interface is extended, it will not conflict with the implementation class code related to the interface. Introduction to default and java: 1. The previous interface was a double-edged sword, which could be oriented to abstraction but not oriented to specific programming. 2. The disadvantage of this is that when you need to modify the interface, you must first modify all classes that implement the interface. 3. When you cannot add new methods to the interface, it will not affect the existing display, so the default method is added to solve the problem for everyone.

How to implement MySQL's default constraint default and zero-fill constraint zerofill How to implement MySQL's default constraint default and zero-fill constraint zerofill May 31, 2023 pm 05:10 PM

Default constraint MySQL default value constraint is used to specify the default value of a certain column. Add default constraint method 1: default; method 2: altertable table name modify column name type default default value; createtablet_user10(idint,namevarchar(20),addressvarchar(20)default'Beijing'--specify default constraints);--altertable table name modify column name type default default value; createtablet_user11(idint,namevarchar(20),addr

How to set the default cache resolution for Tencent Video How to set the default cache resolution How to set the default cache resolution for Tencent Video How to set the default cache resolution Mar 12, 2024 pm 12:20 PM

The Tencent Video app software provides a large number of film and television videos, and popular series are updated 24 hours a day, completely bidding farewell to the film shortage. Everything you want to watch can be found immediately, and the overall viewing experience is more immersive. Open the software and enter your mobile phone number to log in online. Different types of video channels are open. You can search and watch immediately without waiting. The entire plot content is buffered in seconds. The ups and downs of the video plot make people feel more happy. Of course, the definition line can also be adjusted. Whether during playback or batch downloading, you can set the default definition with one click, making the overall viewing experience more enjoyable. Now the editor will provide detailed settings for Tencent Video users online. Ways to cache clarity. 1. Open Tencent Video and click to enter Personal

How to use php default How to use php default Mar 03, 2023 pm 07:22 PM

In PHP, the default keyword needs to be used together with the switch statement to perform different actions based on different conditions. The switch statement is a conditional selection statement. First, the case value that satisfies the condition will be found as the program entry after execution; if all cases are not satisfied, the default entry will be found. If not found, the entire switch statement will be exited. Default is an alternative entry, but for error or logic checking, the default branch should be added to the switch statement.

See all articles