I am using ubuntu and mysql. I have a list of many .sql files, like 1.sql, 2.sql, 3.sql ... 100000.sql

I need to insert them into the database

    mysql mydb < *.sql

Gives me:

    -bash: *.sql: ambiguous redirect

Any idea how can i do it from command line. (I know i can write a pyhton script to do it with no probelm)

Thanks.

link|improve this question

62% accept rate
feedback

2 Answers

up vote 2 down vote accepted

I have no MySQL available but I believe cat *.sql | mysql mydb should work.

link|improve this answer
feedback

If Nifle's answer doesn't work, then try:

for f in *.sql
do
    mysql mydb < "$f"
done
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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