I recently moved my MySQL database to a new server and it has given me some problems i have newer experienced with MySQL before.
My table columns are set to "Default => None" and my table has been generating the default value depending on the Datatype. But now when i try to insert into a table i'm getting this error message:
"#1364 - Field 'column_name' doesn't have a default value" and then nothing is inserted into the table.
What can i do to make the "Default" choose it's own value?
It's not saving into database definetly because the field 'column_name' (and maybe some others) is checked as "NOT NULL". It means that the value of that field must be something other that NULL (NULL - no data at all)
Marking fields as not null is usually a great way to ensure that some data will always be present in the field. Depending on your needs, you can also mark it as NULL so it will never throw an error and will save into DB without the need for anything to be inserted into a specified field.
It means you have 2 options:
Mark your field as NULL (first check if your field is required to have some value or not).
your_field VARCHAR(250) NULL;
Add a default value to the field so if no data is provided on insert, it will put something you defined. For example:
your_table CHANGE COLUMN
your_field VARCHAR(250) NOT NULL DEFAULT 'some_default_value';
And ofcourse match your field type to the field your are going to change.