views:

338

answers:

4

I have a new database, similar to the old one but with more columns and tables. So the data on the old table is still useable and needs transferring.

The old database is on a different server to the new one. I want to transfer the data from one database to the other.

I have navicat, but it seems to take forever using the host to host data transfer. Also downloading a sql file then executing that takes too long also (it executes about 4 inserts per second).

The downloaded SQL file is about 40mb (with complete insert statements). The final one would probably be 60mb to 80mb.

What's the best way to transfer this data? (a process I will need to repeat a few times for testing)

A: 

Can you not transfer only a portion of the data for testing first? Then, later, transfer the entire thing when you're satisfied with test-results?

Jonathan Sampson
+3  A: 

Doing a mysqldump on the source machine and then slurping it in on the other side, even on a 40-100MB file is well within reason. Do it from the command line.

(source machine)
mysqldump -u user -p password database > database.sql

..transfer file to recipient machine...

(recipient machine)
mysql -u user -p password database < database.sql
Cody Caughlan
A: 

(it executes about 4 inserts per second)

That sounds more like there's something wrong with your database.. Are you sure that's alright?

Tim
Or perhaps we've got some massive fields. Unbelievably massive.
Jonathan Sampson
the sql dump is a text file on my local machine. I'm executing it through navicat. data looks like it's uploading at 4kb/s - slow. it's not the db, it's navicat.
ed209
Importing can be unbelieveably slow for InnoDB tables. Try changing the table to MyISAM, import the data and then convert it back to InnoDB. Also watch out for indexes on HUGE tables.
BlaM
A: 

Cody thank you for the direction. For some reason it did not work for me, but the below did on my redhat linux server:

(recipient machine) mysql -u [username] -p -h localhost database < database.sql

(source machine) I just used php myadmin

Is there a command that can be run to pull the DB from another server something along the lines of: mysqldump -u [username] -p -h [host address] [dbname] > [filename].sql Thanks

topCweb
Well, in theory you could do it all in one command. The security levels would have to be open enough such that you can access one of the machines via its external address and not from localhost or something. The overall plan is to pull from one machine and then pipe it into another, like:mysql [options] source_db_name | mysql [options] recipient_db_nameWith appropriate host/user/password parameters for each side. Like I said, this requires the security to be such that you can connect from the appropriate host(s).
Cody Caughlan