Solved

Moving Data in PHP MySQL from one table with records to the same named table with no records

Posted on 2013-06-06
8
288 Views
Last Modified: 2013-06-10
I have a database i have installed with a product open source Bug Ticketing system called Mantis. I installed Mantis on a new website with a new ISP. (no Records in this DB) The old ISP had the same version of Mantis with just a few records in it I wanted to move those records....that data to the new site. Is this possible if so how do I do that. Please advise thank you.
0
Comment
Question by:ruavol2
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 31

Assisted Solution

by:Frosty555
Frosty555 earned 167 total points
ID: 39227141
If this is a one-time thing, the easiest way to do it is to mysqldump the contents of the old table, manually edit the .SQL dump file to have the new database/table name, and then execute the dump query against your MySQL server.

If you have PHPMyAdmin installed, you can use the Export/Import options to do this, otherwise you can use the mysqldump command line utility on your server

http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
0
 

Author Comment

by:ruavol2
ID: 39227180
I have already imported the tables they are in the DB twice. In fact they have a weird icon and the column under the PHP MyAdmin Table list on the far left. See image attached.
So the tables are in there twice. One empty and one with records. Is there a simply way to say put these records in that table with the same name......? Like Mantis_Users    to   Mantis_Users

Note the highlighted area in yellow and the Mantis (31) representing the tables I imported with records the Mantis Tables at the higher level are the tables I installed to for the website and are empty........? Does that help
PHPMyAdmin-Mantis.png
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 166 total points
ID: 39227244
Hmm... Some of the tables seem to have a single underscore in the name and others seem to have a double underscore.  Am I seeing that correctly?
0
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 39227330
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:ruavol2
ID: 39227444
julianH Yes I do but that seem to not be answered about a data merge but a table merge. This question asks only about merging the data.

Ray_Paseur Yes there seems to be a double underscore there. Yes and I see why the double underscore seems to signify where the imported tables are They seem to follow the Mantis (31)  tables that are there and flow to the bottom of the 31 list.
0
 
LVL 51

Accepted Solution

by:
Julian Hansen earned 167 total points
ID: 39227528
I think Ray has spotted the problem. Just checked the data you posted in my db and the tables have double underscores.

What is the correct name for the tables - with or without double underscores?

You could probably do a search and replace on the sql file you posted - but I had to kill my text editor while editing that file - it choked after I got 1500 or so lines down. Might be easier to just delete the tables that are there and rename the new ones.

With regard to merging - at the data level you will need a script - PHPMyAdmin just runs SQL queries and the ones in the export dump are create and insert statements - so they will overwrite / add to what you have but won't merge - but from what I gather the other tables are throw away anyway?
0
 

Author Closing Comment

by:ruavol2
ID: 39236480
Thanks to you guys I figured it out. It would seem all I had to do was to delete or drop the empty tables in PHPMyAdmin and then go in and rename the tables by removing the "extra underscore" created apparently by the import. The import put a Mantis__??? infront of the imported tables. It seems to have worked by simply removing the one underscore. Thanks for your help gentlemen....
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39236515
Glad you got it pointed in the right direction!  Best regards, ~Ray
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now