LOAD DATA LOCAL INFILE not working in RDS

2019-08-07 16:53发布

I have wordpress website and have created plugin to import csv to a table. Database is in RDS. Here is the sql I have used

LOAD DATA LOCAL INFILE 'my.csv' INTO TABLE tablename CHARACTER SET UTF8 FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\r\n' IGNORE 1 LINES

( ID, Name Address )

When I run this sql in sqlyog in the same database ( database in RDS ) this works perfectly. Please note csv file used is on my windows folder and given absolute path. However when I run this sql from the plugin on the linux server (where the website is hosted), wordpress gives message saying Load data local infile is not supported. I have another website where this works fine and this is also hosted on AWS as this one and has the same configuration such as database in RDS and mysql version 5.5+ on both servers.

Am I missing anything here. Any help will be appreciated.

Thanks in advance.

1条回答
叼着烟拽天下
2楼-- · 2019-08-07 17:57

Amazon RDS hosted service doesn't support the load from files. Hence it gives error.

Hence, you can't load the CSV. Here is approach.

  1. Convert your CSV data into insert into table(....) SQL data.
  2. Load your data using command like below.

     mysql -h <Host> -u <username> -p<Password> < Your_file.sql
    
查看更多
登录 后发表回答