How to insert selected columns from a CSV file to a MySQL database using LOAD DATA INFILE

后端 未结 6 799
甜味超标
甜味超标 2020-11-27 10:13

I have a CSV file which contains 10 columns. I want to select only some columns from that file and load them into a MySQL database using the LOAD DATA INFILE co

6条回答
  •  孤城傲影
    2020-11-27 10:44

    For those who have the following error:

    Error Code: 1290. The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

    You can simply run this command to see which folder can load files from:

    SHOW VARIABLES LIKE "secure_file_priv";
    

    After that, you have to copy the files in that folder and run the query with LOAD DATA LOCAL INFILE instead of LOAD DATA INFILE.

提交回复
热议问题