I imported data from MySQL to a CSV. Now I am trying to import it into another machine’s MySQL. But I want to preserve the original auto-increased id‘s values.
I tried this:
LOAD DATA INFILE '/tmp/region.csv'
INTO TABLE regions
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
IGNORE 1 LINES
(id,name,parent_id,level)
But this didn’t work. Any help?
The “auto increase” field you speak of is “auto increment”. To preserve it, temporarily alter the table to not use AUTO INCREMENT on the ID column, then once imported, alter it back.
E.g
Then: