'phpMyAdmin Database Updates using sql file

I have two machines each with phpmyadmin installed which have a mirror setup - same databases, same tables...and so on.

I updated one of these instances with a new column in a few tables in various databases. I now want to update the other instance to match but when I import the sql.zip file (that I exported from the first machine) I get an error saying that the table (first table) already exists. I know this! I just want to update it.

I thought that when you imported data it checks for the existence of said tables/databases first and then creates them if needed?

What am I doing wrong please?



Solution 1:[1]

When you export your sql.zip file in phpMyAdmin, check the "IF NOT EXISTS" option in the export dialog. That will make the create table statements optional and not error out if the tables already exist.

Solution 2:[2]

  1. Open your sql file on text editor

  2. If you found sytax to make a table just delete it the code looks like this

    CREATE TABLE table_name ( name int(11) ... ... ... ) delete that code on your sql file

  3. Find syntax INSERT INTO then replace with REPLACE INTO ex. INSERT INTO tb_name (id,name) VALUES (1,2) became REPLACE INTO tb_name (id,name) VALUES (1,2)

  4. Then enjoy your SQL Update on other machine

I think my comment is 3 years late and I think the owner of the post already knows the solution. but at least useful for those who just visited here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tyron
Solution 2 Al Zakaria