insert backed up dumps from mysql


/ Published in: Bash
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #!/bin/sh
  2. # creates and fills mysql databases from a directory
  3. # of sql-files named like database.sql
  4.  
  5. for i in `ls -1 $1`;
  6. do
  7. db_name=`echo $i|cut -d'.' -f1`;
  8. cmd="create database $db_name;";
  9. echo will exec: $cmd;
  10. mysql -uroot -p$2 -e "$cmd";
  11. mysql -uroot -p$2 $db_name<$1$i;
  12. done

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.