Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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

share|improve this answer
add comment

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

for f in *.sql
do
    mysql mydb < "$f"
done
share|improve this answer
add comment

Your Answer

 
discard

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.