tags:

views:

446

answers:

3

to run a single file you can run in mysql

.\ filename

or you outside of mysql you can run

mysql < filename

I have a directory of sql files so I'm trying to run them all at once by using a wildcard

*.sql

but it doesn't work.

Any ideas?

A: 

bash:

mysql < <(cat *.sql)
Ignacio Vazquez-Abrams
A downvote with no explanation why...
Ignacio Vazquez-Abrams
i think someone marked this down because running this command gets an error "syntax error near unexpected token `('"
hmak
That's because process substitution needs `bash`. Not `sh`, not `dash`, but `bash` proper. http://tldp.org/LDP/abs/html/process-sub.html
Ignacio Vazquez-Abrams
+2  A: 

Assuming you're using bash:

cat *.sql | mysql

e-t172
thanks worked :)
hmak
A: 
for %S in (*.sql) do mysql -u user_name database_name < %S

or

mysql -u user_name -p password database_name < file.sql
Anuchit