Importing a Large Number of .sql Files to MySQL in One Go!

Importing a Large Number of .sql Files to MySQL in One Go!

Here's a script that would import all of the .sql files in your current directory.

I usually use that in case there are a lot of separate MySQL tables which need to be imported in one single database:

#!/bin/bash

##
# Imports all .sql files in your current direcotry
##

for i in *.sql
do
    echo "Importing: $i"
    mysql your_db_name < $i
    wait
done 

This could be quite useful if you have a lot of tables exported in .sql format which you need to import in a specific database.

Hope that it helps someone :)

 

Coffee For Me