Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

MySQL command I have so far:

 load data infile 'data.txt' into table foo (column_foobar);



Note the tab at beginning of each line. How can I ignore the tab with MySQL so that bar1, bar2, bar3 gets loaded in column_foobar?

share|improve this question
up vote 1 down vote accepted

You may be able to use the LINES STARTING BY clause

load data infile 'data.txt' into table foo LINES STARTING BY '\t'  (foobar);

which will do what you want for that data provided. If your data was for example

bar3    bar4

with a tab between bar3 and bar4 then you would have to use something like

load data infile 'data.txt' into table foo 
LINES STARTING BY '\t'  (foobar);
share|improve this answer
Very good answer. As it turns out I hadn't tabs in my data.txt file, but four spaces, so I ended up using four phyiscal spaces instead of the \t, which worked great! – Stephan Kristyn Nov 7 '12 at 13:41

Can't you just remove the leading tabs with sed 's/^<tab goes here>//' before loading the file?

If you (in bash) push Ctrl+V and then TAB, you will get a tab in the shell that sed can remove.

share|improve this answer
That would add one more step in processing my files. So I prefer lain's solution. – Stephan Kristyn Nov 7 '12 at 14:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.