Skip to content

Instantly share code, notes, and snippets.

@psujit775
Last active June 17, 2022 08:41
Show Gist options
  • Save psujit775/a80ba11e326a73d94d807c1a8b911eec to your computer and use it in GitHub Desktop.
Save psujit775/a80ba11e326a73d94d807c1a8b911eec to your computer and use it in GitHub Desktop.
restore sql file in mysql
USER="root"
PASSWORD_FILE="/root/.local.cnf"
HOST="localhost"
echo "Restoring Databases...."
COUNTER=1
TOTAL_FILES=$(ls *.sql|wc -l)
for SQL in *.sql
do
DB=${SQL/\.sql/}
echo "restoring $DB [ $COUNTER of $TOTAL_FILES]"
mysql --defaults-extra-file=$PASSWORD_FILE -h $HOST -u $USER < $SQL
let "COUNTER++"
sleep 1
done
echo "......Complete ALL DB!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment