Skip to content

Instantly share code, notes, and snippets.

@rafesposo
Last active December 21, 2023 12:28
Show Gist options
  • Save rafesposo/0696d31e9dd9cd5d941e6f4c9c3c0d73 to your computer and use it in GitHub Desktop.
Save rafesposo/0696d31e9dd9cd5d941e6f4c9c3c0d73 to your computer and use it in GitHub Desktop.
Use split.sh for split .sql file by table AND import.sh for import separated files and get file with error
for file in part_*.sql; do
mysql -u root -p'yourpass' DBNAME < "$file"
if [ $? -ne 0 ]; then
echo "Erro ao importar o arquivo: $file"
break
fi
done
awk '/CREATE TABLE/ {if (n) close("part_" n ".sql"); n++; } {print > ("part_" n ".sql")}' yourfile.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment