Import CSV files to Mysql using LOAD DATA LOCAL INFILE

Asked

Viewed 892 times

0

I used the following script to import a file .csv to Mysql using the MySQL WorkBench:

USE test;

LOAD DATA LOCAL INFILE 'exemplo1.csv' INTO TABLE tabela1 fields terminated by ';' lines terminated by '\r';

I saw on several other sites using only the command LOAD DATA INFILE, but my script only works by adding the keyword LOCAL. Can anyone say what it works for? And what’s the point of being used or not.

1 answer

2


The keyword LOCAL is used when the file is on another machine than Mysql is running.

By adding the LOCAL the file will be sent to the server, stored in a temporary folder, and run from there. This works only if the necessary permissions are set.

  • 1

    then but my file. csv is on the same machine as Mysql is running, or the fact that it used XAMPP since I need to access a remote server?

  • @Rodrigo In this case it is necessary to inform the location of the file, for example: 'C: Documents.csv file'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.