I would like to share a script I found quite useful, it’s very basic bash scripting but it still can help the unexperienced ones.
First create a import.sh script
Add the following content to the script:
if [ "$db" = "" ]; then
echo "Usage: $0 db_name user password"
for sql_file in *.sql; do
echo "Importing $sql_file";
mysql --user=$user --password=$passwd $db < $sql_file;
Run the script with the following terminal command:
The script will simply run sequentially all the imports you dumped beforehand.
PS: If you get some Foreign Key errors, you can disable them changing the “for” cycle mysql command with the following: echo "SET FOREIGN_KEY_CHECKS=0" | mysql --user=$user --password=$passwd $db < $sql_file