2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RakeタスクとかでmysqlのLOAD DATA LOCAL INFILEを呼びたい場合

Last updated at Posted at 2016-03-07

こういうSQLをrakeタスクで実行しようとすると


LOAD DATA LOCAL INFILE 'members.csv' INTO TABLE members

エラります

rake aborted!
ActiveRecord::StatementInvalid: Mysql2::Error: The used command is not allowed with this MySQL version:
LOAD DATA LOCAL INFILE 'members.csv' INTO TABLE members

どうしても実行したい場合には、
database.ymlにlocal_infileの設定行が必要です。


default: &default
  adapter: mysql2
  encoding: utf8
  pool: 5
  database: foo
  username: var
  password: foovar
  host: host.foovar.com
  local_infile: true

合わせて読みたい。
MySQL 外部ファイルからのデータインポート方法 - LOAD DATA ... INFILE 構文および mysqlimport コマンド

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?