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

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>