Created
August 22, 2017 14:15
-
-
Save classmember/4e6996119dbd268cd31761c76b9a1479 to your computer and use it in GitHub Desktop.
importing databases
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
# List of databases | |
# \ls -A | grep sql | sed 's/\.sql//g' | xargs | fold -w 80 -s | tr ' ' '|' | column -s'|' -t | |
dbs="admin_wp11 admin_music admin_bestsat admin_exot admin_geek admin_girl | |
admin_tabs admin_birds admin_frogs admin_liveagle admin_exampl admin_practical | |
admin_productive admin_reviews admin_rich admin_sites" | |
# Create databases and users | |
mysql<<<$( | |
for db in ${dbs}; do | |
echo CREATE DATABASE ${db}\; | |
echo CREATE USER \'${db}\'\@\'localhost\' IDENTIFIED BY \'RqaGTWhQ8Zw0Gn5Jmc\'\; | |
echo GRANT ALL PRIVILEGES ON \* \. \* TO \'${db}\'\@\'localhost\'\; | |
echo FLUSH PRIVILEGES\; | |
done | |
) | |
# Import databases | |
for db in ${dbs}; do | |
mysql ${db} < ${db}.sql | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment