Return to Snippet

Revision: 18267
at September 24, 2009 18:40 by 1b0t


Updated Code
#!/bin/sh
# creates and fills mysql databases from a directory 
# of sql-files named like database.sql

for i in `ls -1 $1`;
do
  db_name=`echo $i|cut -d'.' -f1`;
  cmd="create database $db_name;";
  echo will exec: $cmd;
  mysql -uroot -p$2 -e "$cmd";
  mysql -uroot -p$2 $db_name<$1$i;
done

Revision: 18266
at September 24, 2009 18:37 by 1b0t


Initial Code
#!/bin/sh
# creates and fills mysql databases from a directory 
# of sql-files named like database.sql

for i in `ls -1 $1`;
do
  db_name=`echo $i|cut -d'.' -f1`;
  cmd="create database $db_name;";
  echo will exec: $cmd;
  mysql -uroot -p$2 -e "$cmd";
  mysql -uroot -p$2 $cmd<$1$i;
done

Initial URL

                                

Initial Description

                                

Initial Title
insert backed up dumps from mysql

Initial Tags
mysql, Bash, backup

Initial Language
Bash