I'm in the middle of a project development, and I'm frustrated with this problem.

Im running XAMPP under Ubuntu 10.04 (Lucid Lynx)
mySQL version : Ver 14.14 Distribution 5.1.41

The problem is that, mySQL is accepting null values even if the field is declared with
the NOT NULL constraint.


  name VARCHAR(255) NOT NULL,
  age  INT


In the query above. mySQL still accepts the data, even if I do not indicate any value for
the name column. Is there something wrong? Do I need to configure something in mySQL?

I really need help!

In my version of MySQL (5.1.34-community) your code produces the desired error:

Field 'name' doesn't have a default value

So after your INSERT there is really a new row in your table? Or do you just suppress the error messsages?

And I forgot to ask:
What value does name have after the insert? Is it NULL or an empty string? Could it be that somewhere in your configuration the emtpty string is set as a default?

Thank you for your concern sir. This problem is now solved.
I discovered that sql-mode must be set to STRICT_ALL_TABLES in order to produce the
desired error, rather than produce warnings only.

Anyway. Thank you again.