Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

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 Python script to do it with no problem, but I want to do it from the command line)

share|improve this question
up vote 2 down vote accepted

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

share|improve this answer

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .