I have two EC2 instances in AWS. I copied my code and database from Instance #1 to Instance #2 recently. The following SQL stopped working in the my new instance:
INSERT INTO invested_val_nav (username, pf_id, scheme_code, inv_nav, inv_qty, orig_inv_qty, date) VALUES ('xyz@gmail.com','1','120586','40.50000','123.568','123.568','2020-06-08')
The structure of the table where I am inserting is:
In the new instance, this insert is failing with the following error:
#1364 - Field 'category' doesn't have a default value
Mysql versions are:
Instance#2: mysql Ver 14.14 Distrib 5.7.28, for Linux (x86_64) using EditLine wrapper
Instance#1: mysql Ver 14.14 Distrib 5.6.42, for Linux (x86_64) using EditLine wrapper
Where am I going wrong? is there a setting that I need to change in Instance #2 to make my code work?
Advertisement
Answer
Instance #2 was running in STRICT SQL mode whereas Instance # 1 was not. I just changed the mode to ” by the query and it did the trick
mysql> SET sql_mode = '';