I want to create a script that copies all tables in a database to another database.
Obviously I found it faster than dump & restore with mysqldump.
The script below works fine, but the tables are copied one by one in order. (only one process id)
In order to operate faster, i want to make all tables copied at the same time.
Help.
#!/bin/bash
HOSTNAME='127.0.0.1'
QUERY1="select concat('create table ', ' $1','.',table_name , ' like ' , '$2','.',table_name,';') as '' from information_schema.tables where table_schema = '$2'"
QUERY2="select concat('insert into ', ' $1','.',table_name , ' select * from ' , '$2','.',table_name, ';') as '' from information_schema.tables where table_schema = '$2'"
Q1=`mysql -uaccount -ppass -h$HOSTNAME -e "$QUERY1"`
Q11=`mysql -uaccount -ppass -h$HOSTNAME -e "$QUERY2"`
C1=`mysql -uaccount-ppass -h$HOSTNAME -e "CREATE DATABASE $1"`
Q2=`mysql --default-character-set=utf8 -v -t -uaccount-ppass -h$HOSTNAME -e "$Q1"`
Q22=`mysql --default-character-set=utf8 -v -t -uaccount-ppass -h$HOSTNAME -e "$Q11"`
sh test.sh newdb_01 olddb_01