2

Given the following table:

CREATE TABLE Test (
 id int(10) unsigned NOT NULL PRIMARY KEY,
 value int(10) unsigned NOT NULL
) ENGINE=InnoDB;

If I insert a value with only the id field set:

INSERT INTO Test (id) VALUES (1);

On my development server, I get a warning:

Warning: #1366 Incorrect integer value: '' for column 'value' at row 1

On my production server, I get an error:

ERROR 1364 (HY000): Field 'value' doesn't have a default value

What should I configure on my development server to make it behave like my production server?

3

Have a look at http://dev.mysql.com/doc/refman/5.5/en/sql-mode.html

You can set this for your current session, or in your mysql config

my.cnf (Unix operating systems) or my.ini (Windows)

sql-mode="modes"

On your production server use the following query to determine the current mode:

SELECT @@GLOBAL.sql_mode;
SELECT @@SESSION.sql_mode;

On your development server you can set it for the current session with

SET GLOBAL sql_mode = 'modes';
SET SESSION sql_mode = 'modes';
  • 1
    Thanks, the difference was STRICT_TRANS_TABLES that was set on my production server but not on my development server! – Benjamin Dec 13 '14 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.