User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 403,115 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,386 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums

Copy tables from one MySql DB to another MySql DB

Join Date: Jul 2005
Posts: 3
Reputation: mshavel@optonli is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mshavel@optonli mshavel@optonli is offline Offline
Newbie Poster

Copy tables from one MySql DB to another MySql DB

  #1  
Jul 5th, 2005
Hello,

I'm running 3.25.54 on a linux RedHat server.

Here is my scenario and what I'd like to do.

I have two databases

d1
d2

d1 has some tables in it that I want to be in d2 instead of being in d1.
My task is to get some of the tables in d1 into d2 and then remove them
from d1.

Here's what I'm thinking of doing.

1. Shut down my mysql server (or make sure nothing is being written to
the tables in question - I have one perl script writing to this table.
I can disable the perl script to not write anything to it.)
2. Issue a cp -p command in /var/lib/mysql/d1 to copy the selected .frm
.MYI and .MYD files into /var/lib/mysql/d2
3. Bring the mysql server back up and tell my perl script to now write
to the moved tables in d2 and NOT d1.
4. Drop the table I moved out of d1 using the DROP TABLE command.


I just want to know if there are any gotcha's hidden in this method. I'm
particularly concerned with moving the tables using cp -p from one
database to another. Are there any values in the .frm .MYI or .MYD files
that refer to the database they reside in? In other words, does the
table I've moved from d1 into d2, still think it belongs in d1 or does
the simple act of moving it into /var/lib/mysql/d2 now make a table in
d2?

Thanks very much!!

I have the New Riders MYsql book but I can't seem to find the answer to
this question.

Mike

mshavel@optonline.net
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 2:22 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC