Go Back   Cloud Computing > Support > MySQL Issues.
 

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 03-14-11, 11:59
BOD Member
 
Join Date: Nov 2010
Posts: 95
Default Transferring MySQL DB?

Hi

Is it possible to transfer MySQL database from one web host to another with the help of SSH? If it's possible, what are the command lines? And how difficult it is?
Reply With Quote
  #2 (permalink)  
Old 03-14-11, 12:09
BOD Member
 
Join Date: Nov 2010
Posts: 91
Default

You can follow the below command lines.

Quote:
shell> mysqladmin -h 'other_hostname' create db_name
shell> mysqldump db_name | mysql -h 'other_hostname' db_name
Reply With Quote
  #3 (permalink)  
Old 03-14-11, 12:12
Kristine Habeck's Avatar
BOD Member
 
Join Date: Nov 2010
Posts: 122
Default

If you need to copy a database from a remote machine over a slow network.

Quote:
shell> mysqladmin create db_name
shell> mysqldump -h 'other_hostname' --compress db_name | mysql db_name
Reply With Quote
  #4 (permalink)  
Old 03-14-11, 12:19
Rozanne's Avatar
BOD Member
 
Join Date: Nov 2010
Posts: 116
Default

You can also save the dump in a file. Move the file to the target system, and then upload the file into the DB there.

Quote:
shell> mysqldump --quick db_name | gzip > db_name.gz
Reply With Quote
  #5 (permalink)  
Old 03-14-11, 12:20
BOD Member
 
Join Date: Nov 2010
Posts: 104
Default

You can also try this one to copy entire mysql db

Quote:
mysqldump --alldatabases | mysql -h 'other host name'
If you want to copy one db

Quote:
mysqldump dbname | mysql -h 'other host name' dbname
To copy only one table

Quote:
mysqldump dbname tablename | mysql -h 'other host name' dbname
Probably you'll need to use the -u and -p options if you do not have the client login set in your config file. I've assumed that you have password root--. Also you'll need to be a user that has create and drop privileges at whatever level you required to perform the copy. Additionally you'll have to enable mysql access to the DB on the other host's server machine.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump


All times are GMT -6. The time now is 00:49.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Copyright © 1999-2012, BODHost Ltd. All rights reserved.