Jump to content

Move data from 1 database to another


daveoffy

Recommended Posts

I would try exporting rows from first database into a CSV file.

Edit the file (either by hand if small, or by custom script if large) so that it fits into second table.

Import the file into second table using LOAD DATA INFILE

Link to comment
Share on other sites

Using PhpMyAdmin you can

 

Go to the members table

Go to Export

Export for CSV MS Excel

In the options put the field names in first row

tick save as file and save to your computer

 

Do the same for the profile table

The just copy and paste the columns from the members spreadsheet to the profile spreadsheet.

 

When you have the file as you need, then delete the column names from the first row

 

 

Import the data back in by going to the profile table and clicking import tab

 

You can import using CSV LOAD Data, and in fields terminated by, replace ; with a comma (,).

 

 

Link to comment
Share on other sites

you would select the records. and run through in a loop saving the info you need from DB1 to columns in DB2

 

 

<?php

$query = "SELECT * FROM DB1";

 

$result = mysql_query($query) or die(mysql_error());

 

while($row = mysql_fetch_array($result)){

 

 

mysql_query("INSERT INTO DB2

(username) VALUES($row['username']) ")

or die(mysql_error()); 

 

}

?>

 

Link to comment
Share on other sites

An easy way of doing that is by simply backing up your database first, which means, you have to back up the whole database or all the tables in that database... Then, you create the new database and restore the data which you backed up.

 

If you dealing with mySQL, then, you can use 'phpmyadmin' which does it easily, you simply open the database there and click on 'Export', then click on 'Restore' to save the data in the new database

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.