0
LOAD DATA
LOCAL INFILE "file.txt"
REPLACE INTO TABLE file
FIELDS TERMINATED BY '|'
(attribute1, attribute2)
LOAD DATA
LOCAL INFILE "file2.txt"
REPLACE INTO TABLE file2
FIELDS TERMINATED BY '|'
(attribute3, attribute4)

I have a single text file composed of several of these "LOAD DATA" commands. I receive an error message saying line 6, or the start of the 2nd command, is not proper syntax. And if I try to introduce a "lines terminated by '\n'" code, it says it is not allowed with my mysql version.

7
  • 3
    Perhaps you need to terminate the individual LOAD DATA statements? Commented Oct 21, 2013 at 17:10
  • 1
    Yes, you should add a ';' at the end of each load statement. And what version of MySQL you are using? Commented Oct 21, 2013 at 17:12
  • The ';' helped remove the 2nd error message, but now it points to line 1 and says "the used command is not allowed with this mysql version". Commented Oct 21, 2013 at 17:15
  • What is the version there? Commented Oct 21, 2013 at 17:16
  • 1
    try add local-infile=1 into your [mysqld], see this stackoverflow.com/questions/10762239/… Commented Oct 21, 2013 at 17:18

1 Answer 1

1

You should add a ';' at the end of each load statement.

LOAD DATA
LOCAL INFILE "file.txt"
REPLACE INTO TABLE file
FIELDS TERMINATED BY '|'
(attribute1, attribute2);


LOAD DATA
LOCAL INFILE "file2.txt"
REPLACE INTO TABLE file2
FIELDS TERMINATED BY '|'
(attribute3, attribute4);

See also ERROR 1148: The used command is not allowed with this MySQL version

You can specify that as an additional option when setting up your client connection:

mysql -u myuser -p --local-infile somedatabase
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.