Created
July 20, 2018 20:54
-
-
Save je8n/0f68e1042f1215a8d2cef51615e07cd9 to your computer and use it in GitHub Desktop.
linux foreach import several sql files in folder with mysql terminal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#query: mysql-u[username] -p[password] -e [query] | |
for SQL in *.sql; do DB=${SQL/\.sql/}; echo importing $DB; mysql -uroot -p -e "create database $DB"; done | |
# first create filenames database | |
for SQL in *.sql; do DB=${SQL/\.sql/}; echo importing $DB; mysql -uroot -p $DB < $SQL; done | |
#import file to filename database |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment