23

How would I do the following command, with a local file, on a remote database (different machine) ?

$MYSQL_PATH/mysql -u root -h remote.net files -e "
    LOAD DATA INFILE '$1'
    INTO TABLE $TABLE_NAME
    FIELDS TERMINATED BY ','
      (size, @d2, @d3, @d4, @d5, path)

The problem seems to be that the INFILE at /tmp/infile.txt is not being recognized remotely. What would be the correct way to accomplish the above?

David542
  • 104,438
  • 178
  • 489
  • 842

2 Answers2

38

LOAD DATA INFILE loads a file on machine the MySQL server is running on.

Use LOAD DATA LOCAL INFILE to load a file located on your client machine.

nos
  • 223,662
  • 58
  • 417
  • 506
10

Don't forget to include --local-infile=1 when doing this:

$MYSQL_PATH/mysql -u root -h remote.net files --local-infile=1 -e "
    LOAD DATA LOCAL INFILE...
David542
  • 104,438
  • 178
  • 489
  • 842