禁用MySQL严格模式 [英] Disabling MySQL Strict Mode

查看:83
本文介绍了禁用MySQL严格模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将5000个csv文件扫描到数据库中.遗憾的是文件的''为0.因此,每当我运行脚本时,它就会崩溃.我听说可以通过简单地禁用严格模式来避免此错误.因此,我尝试禁用严格模式,以允许我将数字字段的空字符串读为0.但是错误仍然存​​在.

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.

那么禁用严格模式是否可以将''读入int字段? (是两个qoutes,即空字符串)

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

如果是,为什么设置

sql_mode =''

sql_mode=''

my.ini配置文件中的问题无法解决.

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

谢谢!

推荐答案

我猜您是使用LOAD DATA INFILE命令导入CSV文件的.在执行此命令之前,键入:

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

SET sql_mode = '';

有关各种SQL模式的更多信息可以在文档中找到.

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

这篇关于禁用MySQL严格模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆