views:

27

answers:

1

how to write a bash script which will dump a database and restore it. there should be two arguments. first one is the name of db which is going to be dumped and another one is name of the db in which i am going to restore the previously dump data.

+1  A: 

Try this:

#!/bin/bash
mysqldump $1 > test.sql
mysql $2 -uusername -ppassword < test.sql
rm test.sql

May be you'll need any optional arguments to mysqldump and mysql commands

netme