LoginSignup
0
0

MySQLのLOAD DATAを許可する

Last updated at Posted at 2023-10-05

my.cnf(環境によってファイル名が違うかも)にroot権限で下記を追加。ubuntu22は/etc/mysql/mysql.conf.d/mysqld.cnfでした。

[mysqld]
local-infile=1

さらに、mysqlログイン時にオプションを追加

mysql -u username -p --local-infile=1

で、インポートしたいテーブルがあるデータベースを選択

use this-database;
LOAD DATA LOCAL INFILE '/home/username/foldername/file.csv' INTO TABLE table-name FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' (id, company_name, phone, address1, address2, website, email, fax);
0
0
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
0
0