Solved

Import data - Problem with autoincrement field

Posted on 2004-09-19
1
263 Views
Last Modified: 2010-05-18
Hi.

Let's say i have TABLE-1 in mysql-server1 with 2 columns :

id PRIMARY auto-increment.
name TEXT

In TABLE-1 i have 2 rows

id  name
1   JOHN
2   MIKE

If i make an export of TABLE-1 in mysql-server2 with mysqldump, i get a file that contain
INSERT INTO TABLE-1 VALUES (1,'ROBERT');
INSERT INTO TABLE-1 VALUES (2,'JASON');


How could I do to import data from mysql-server2 without having problem with "DUPLICATE KEY" of id.

Can i get this export with mysqldump, typing a specific option ?? : (that would solve my problem)
INSERT INTO TABLE-1 VALUES ('','ROBERT');
INSERT INTO TABLE-1 VALUES ('','JASON');

Or do i need to do something while importing.


My real world table have many columns and about 600Mb of data, so i need an adapted solution.

Thanks



0
Comment
Question by:eeolivier
1 Comment
 
LVL 26

Accepted Solution

by:
ushastry earned 125 total points
ID: 12099155
HI,

Make a backup of the database before doing anything here..

I guess your import file is something like this.. say dump.sql .. and make sure the autoincrement column looks like ''

INSERT INTO TABLE-1 VALUES ('','ROBERT');
INSERT INTO TABLE-1 VALUES ('','JASON');
then use this command to insert/import..

mysql -u USER -p DBNAME < dump.sql

0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

A lot of articles have been written on splitting mysqldump and grabbing the required tables. A long while back, when Shlomi (http://code.openark.org/blog/mysql/on-restoring-a-single-table-from-mysqldump) had suggested a “sed” way, I actually shell …
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

11 Experts available now in Live!

Get 1:1 Help Now