≡ Menu

How to: Transfer MySQL database from one server to another UNIX / Linux server

Q. I’m moving my server from local data center to another data center. I’ve new server up and running. My site is dynmic and I’d like to transfer MySQL database from old server to new server. How do I make transfer smooth and successful?

. The best and secure way is to use ssh to transfer database to another server. You need to use following tools:

=> SSH client
=> SSH Server on remote box
=> mysqldump command
=> UNIX pipes

Let us say you would like to Transfer MySQL database called foo to remote box called bar, enter the following command at shell prompt:
$ mysqldump foo | ssh user@remote.box.bar.com mysql foo

You can just copy table called chocolate (from recipe database) to remote database called icecream using same syntax:
$ mysqldump recipe chocolate | ssh user@remote.box.com mysql icecream

Share this tutorial on:

Like this? Follow us on Twitter OR support us by using Patreon

{ 2 comments… add one }
  • rc3 July 13, 2009, 9:07 pm

    This is by far the most useful ssh usage I ever seen. Thanks for the tip.

  • euan October 7, 2010, 10:10 am

    i have a database that i want to make every time i have the back up server is on but not shure how to do that any ideas

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , ,