1

I have dir with a lot of .sql files. I want to import them all at once when creating the database. Is it possible without doing it one-by-one?

I already tried

mysql -u user -p Database < *.sql

but no luck.

1 Answer 1

1

You can do it so:

cat *.sql | mysql -u user -p Database

OR

cat *.sql >/tmp/all.sql
mysql -u user -p Database < /tmp/all.sql
rm /tmp/all.sql
Sign up to request clarification or add additional context in comments.

7 Comments

cat is the solution here as it will combine all the .sql files together into one.
i can't do that because Database each sql file is a diffrent database
You can put the name of each Database in the File at the top with USE DBNAME; So do you must not select one at the commandline
You mus put one line in each sql file with USE DATABASENAME; to select a DB whenthe sql is executed
i got your idea, but isn't there any other way since they more than 100databases ?
|

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.