Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling MySQL Strict Mode

Tags:

sql

mysql

I am scanning 5000 csv files into a database. Regrettably the files have '', for 0. Thus when ever I run my script it crashes. I heard that this error is possible to avoid by simply disabling strict mode. So I attempted to disable strict mode to allow me to read in an empty string as a 0 for my numeric fields. However the error persisted.

So does disabling strict mode allow '' to be read into a int field? (the '' is two qoutes i.e. empty string)

If so why did setting

sql_mode=''

in the my.ini config file not fix the problem.

Thank you!

like image 446
Orlan Avatar asked Jun 14 '12 19:06

Orlan


1 Answers

I guess you import the CSV file using LOAD DATA INFILE command. Before you execute this command, type:

SET sql_mode = '';

More information about various SQL modes can be found in the documentation.

like image 169
jkrcma Avatar answered Sep 20 '22 01:09

jkrcma