Howto Migrate MySQL DB or Table To Another Host

This is an easy script to move a database or table from one MySQL host to another quickly and easily.   The following code can be run straight from the command line with a copy/paste of the variables, or put in a .sh file and run as a script.

fromuser=
frompass=
fromhost=
fromdatabase=
fromtable=
touser=
topassword=
tohost=
todatabase=
emailaddress=

date && mysqldump –user=$fromuser –password=$frompass –                 host=$fromhost –opt –skip-lock-tables  –compress $fromdatabase $fromtable | mysql –user=$touser –password=$topassword –host=$tohost $todatabase && date && echo “script is done” | mailx -s “Script is done” $emailaddress

[ad#google-horzbanner-1]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: