Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MYSQL command to execute multiple .sql files

Tags:

sql

mysql

oracle

I am wanting to write and execute a single mysql .sql file that will execute multiple other .sql files. I am looking for something equivalent to Oracle's:

@script1.sql
@script2.sql
@script3.sql

Does MYSQL have a command?

like image 317
drquiz Avatar asked Mar 14 '11 04:03

drquiz


1 Answers

From bash or any shell, you can run as follows

cat script*.sql | mysql -u root -pYOURPASSWORD  dbname

This would execute all for your sql files for 'dbname'

Cheers!!

like image 102
Jay Dave Avatar answered Sep 21 '22 07:09

Jay Dave