How to combine 2 mysql databases

Discussion in 'MySQL' started by carl_in_florida, Sep 11, 2008.

  1. #1
    I have 2 sites with identical database structures. I want to combine the two into one site.

    If I try to export database "A" and import it into database "B." When i try, i get an error that there is already a row "1"

    How do i get past the conflicting increments? do I export one without the id numbers? if so, how do you do that?
     
    carl_in_florida, Sep 11, 2008 IP
  2. greny

    greny Peon

    Messages:
    162
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi,

    Go to your phpMyAdmin in database A. I guess you are trying to export/import only one table?

    Anyways, in phpMyAdmin open the table, click "SQL", change the SQL query to SELECT all fields without the field that gets you the duplicate error (for example ID that has auto_increment).

    For example:

    Normal query: SELECT id, name, address, city FROM table

    You do: SELECT name, address, city FROM table

    Click 'Go'. It will show you the results. Now just click 'Export' (not the one in the header but in the 'Query results operations' area). It will forward you to the export page. Just press GO and your done.

    Now you can import it into your database 'B'.

    Hope it helps. :) Good luck! ;)
     
    greny, Sep 11, 2008 IP
    carl_in_florida likes this.
  3. carl_in_florida

    carl_in_florida Active Member

    Messages:
    1,066
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    90
    #3
    Wish I would have seen this before I wastd half a day doing something much more complicated.
     
    carl_in_florida, Sep 15, 2008 IP
  4. greny

    greny Peon

    Messages:
    162
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Good that it worked for you. :)
     
    greny, Sep 15, 2008 IP