Created
September 29, 2017 01:28
-
-
Save paolooo/53569e275a3873161a0508399fa02016 to your computer and use it in GitHub Desktop.
Import db tables
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
#!/bin/bash | |
################################################ | |
# @author Nino Paolo Amarillento # | |
################################################ | |
# Usage : | |
# | |
# $ ./importer-loop.sh localhost root db_name dir | |
################################################ | |
[ $# -lt 3 ] && echo "Usage: $(basename $0) <DB_HOST> <DB_USER> <DB_NAME> <DIR>" && exit 1 | |
HOST=$1 | |
USER=$2 | |
DB=$3 | |
DIR=$4 | |
[ -n "$DIR" ] || DIR=. | |
DIR+="/*.sql" | |
echo "DB password: " | |
read -s DB_PASS | |
for f in $DIR | |
do | |
echo "Importing $f table to $DB..." | |
mysql -u $USER -h $HOST -p$DB_PASS $DB < $f | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment