abiku
abiku

Reputation: 2246

Import many .SQL files at once

I am new to Mac OS. I have installed navicat and sequel pro. I have a MySQL database copy dumped to about 100 .sql files (one for each table.)

I want to import them to my localhost newly created DB. How can I do this with Navicat or Sequel Pro?

There is only information about importing one file at once...

Upvotes: 3

Views: 10572

Answers (1)

Jason
Jason

Reputation: 15335

I'd combine them as @tadman mentioned into one file using the terminal. If all your files are in ~/Documents/sql as an example...

cat ~/Documents/sql/*.sql > complete.sql

Then use mysql to import them:

mysql -u [MySQL_USER] -p [DBNAME_TO_IMPORT_INTO] < ~/Documents/sql/complete.sql

OR, all in one step as @eggyal mentioned

mysql -u [MySQL_USER] -p [DBNAME_TO_IMPORT_INTO] < ~/Documents/sql/*.sql

You'll be prompted for your MySQL password in both cases but either should do the trick. If you don't want to use the terminal to import into MySQL the file made with cat above can be imported with either Navicat or Sequel Pro.

Upvotes: 15

Related Questions