1

I recently updated my MySQL (and wamp to v3) and moved my old databases there.

Previously, field types such as varchar, char, text, etc would assume a default value of empty string if no value was given (even though I had no explicitly set this default while creating the table structure ).

But after the update when I try to run my previously working code, it gives me exceptions that

Field <field_name> doesn't have a default value

I'm guessing this is a setting in mysql or something. can anyone help me out?

thanks.

George G
  • 7,443
  • 12
  • 45
  • 59
Ahmed-Anas
  • 5,471
  • 9
  • 50
  • 72

1 Answers1

3

Turns out strict mode was enabled.

disabled strict mode by changing the line

sql-mode="STRICT_ALL_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_AUTO_CREATE_USER"

to

sql-mode=""

reference: https://support.kayako.com/article/472-how-do-i-disable-mysql-strict-mode-on-the-server

Ahmed-Anas
  • 5,471
  • 9
  • 50
  • 72
  • To configure using SQL, use `mysql -u root -p -e "SELECT @@GLOBAL.sql_mode;"` to get settings and `mysql -u root -p -e "SET GLOBAL sql_mode = 'yourmodifiedsettingshere';"` to set them. – DustWolf Dec 14 '20 at 08:01