这是我的完整脚本.
我试图做一个rake任务,从目录中的文件收集数据并将它们加载到mysql中.
我修复了local-infile = 1,没什么用.它只是给我错误
namespace :db do namespace :load do desc "Load PropertIEs into DB" task :propertIEs => :environment do MysqL2::ClIEnt.default_query_options[:connect_flags] |= MysqL2::ClIEnt::LOCAL_fileS @files = Dir.entrIEs("db/property_website_scripts/") connection = ActiveRecord::Base.connection() for file in @files next if file == "." || file == ".." sql = "LOAD DATA LOCAL INfile '#{Rails.root}/db/property_website_scripts/#{file}' INTO table propertIEs FIELDS TERMINATED BY '|' lines TERMINATED BY '\r\n' (property_type,property_for,city,state,country......);" connection.execute(sql) end #updating created at and updated at Property.update_all({:created_at => Time.Now,:updated_at => Time.Now},"created_at IS NulL") end endend
最佳答案这篇文章的解决方案对我有用:Enabling local-infile for loading data into remote mysql from rails将其添加到database.yml
local_infile:true
总结以上是内存溢出为你收集整理的Mysql2 ::错误:此MySQL版本不允许使用命令:LOAD DATA LOCAL INFILE全部内容,希望文章能够帮你解决Mysql2 ::错误:此MySQL版本不允许使用命令:LOAD DATA LOCAL INFILE所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)