Linux – Import Multiple .sql dump files into mysql database

If you have a directory with a bunch of .sql files that mysql dumps of each database on my server.


database1-2011-01-15.sql database2-2011-01-15.sql …

To import all to the db we can:

ls -1 *.sql | awk '{ print "source",$0 }' | mysql --batch -u {username} -p{password} {dbname}

Leave a Reply

Your email address will not be published. Required fields are marked *