mysql> create table HCDR.bureau_balance ( AA integer, BB numeric(5,0), CC varchar(3));
Query OK, 0 rows affected (0.07 sec)
mysql> DROP TABLE HCDR.bureau_balance;                                          Query OK, 0 rows affected (0.05 sec)
mysql> LOAD DATA INFILE '/Users/XXXX/bureau_balance.csv' INTO TABLE HCDR.bureau_balance;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ureau_balance' at line 1


mysql> SELECT @@global.secure_file_priv;
| @@global.secure_file_priv |
| NULL                      |
1 row in set (0.00 sec)


$ sudo vi /etc/my.cnf
secure-file-priv = ""


$ mysql.server restart
Shutting down MySQL
Starting MySQL
$ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.11 Homebrew

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SELECT @@global.secure_file_priv;
| @@global.secure_file_priv |
|                           |
1 row in set (0.00 sec)


mysql> LOAD DATA INFILE '/Users/XXXX/bureau_balance.csv' INTO TABLE HCDR.bureau_balance IGNORE 1 LINES;
ERROR 1265 (01000): Data truncated for column 'AA' at row 1

区切り文字がデフォルトだと、commaになってなかったので、エラーが出ていた。なので、下記の形でTERMINATED BY を使って区切り文字を指定してあげる

LOAD DATA INFILE '/Users/XXXX/bureau_balance.csv' INTO TABLE HCDR.b    ureau_balance FIELDS TERMINATED BY ',' IGNORE 1 LINES;
  • SHELLから実行
mysql -uroot -p HCDR < create_bureau_balance.sql
DROP TABLE HCDR.bureau_balance;
-- などのsqlを記入