debugsqlMinor
How do I set the MySQL error level?
Viewed 0 times
errorthelevelmysqlhowset
Problem
Given the following table:
If I insert a value with only the
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?
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?
Solution
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)
On your production server use the following query to determine the current mode:
On your development server you can set it for the current session with
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';Code Snippets
sql-mode="modes"SELECT @@GLOBAL.sql_mode;
SELECT @@SESSION.sql_mode;SET GLOBAL sql_mode = 'modes';
SET SESSION sql_mode = 'modes';Context
StackExchange Database Administrators Q#86026, answer score: 4
Revisions (0)
No revisions yet.