Importing sql file - duplicate entry error Importing sql file - duplicate entry error
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Importing sql file - duplicate entry error

Started by lolainslacks, August 28, 2010, 12:33:51 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

lolainslacks

Hello,

I'm trying to change my albums permissions from "2" (registered users only) to "0" (public for everyone) all at once, so I exported the .sql file, changed all "2"'s to "1"'s, saved and then when I go to phpmyadmin to import the file, I get this error:

QuoteError

SQL query:

-- -- Dumping data for table `cpg_albums` -- INSERT INTO `cpg_albums` (`aid`, `title`, `description`, `visibility`, `uploads`, `comments`, `votes`, `pos`, `category`, `owner`, `thumb`, `keyword`, `alb_password`, `alb_password_hint`, `moderator_group`, `alb_hits`) VALUES (1, 'Posters', '', 0, 'NO', 'YES', 'YES', 100, 7, 1, 5, '', '', '', 0, 5), (217, 'Promotional Stills', '', 0, 'NO', 'YES', 'YES', 101, 26, 1, 31259, '', '', '', 0, 25), (4, 'Posters', '', 0, 'NO', 'YES', 'YES', 100, 8, 1, 570, '', '', '', 0, 4), (215, 'May 17, 2004', 'Venue: Brooklyn\r\nLocation: New York City, New York, USA', 0, 'NO', 'YES', 'YES', 4, 33, 1, 6334, '', '', '', 0, 5), (6, 'Screen Captures', '', 0, 'NO', 'YES', 'YES', 102, 8, 1, 694, '', '', '', 0, 17), (7, 'Posters', '', 0, 'NO', 'YES', 'YES', 100, 9, 1, 706, '', '', '', 0, 5), (216, 'August 6, 2004', 'Location: New York City, New York, USA', 0, 'NO', 'YES', 'YES', 5, 33, 1, 6189, '', '', '', 0, 8), (9, 'Screen Captu[...]

MySQL said: Documentation
#1062 - Duplicate entry '1' for key 1

I have over 1,000 albums so I don't want to change the permissions one by one. What do I do to fix this error?

Thanks in advance!

Nibbler

You need to empty the table before you import the file. Better yet, just change them all with a db query


UPDATE cpg_albums SET visibility = 0 WHERE visibility = 2

lolainslacks

Where do I go? To "Query" and then paste "UPDATE cpg_albums SET visibility = 0 WHERE visibility = 2" in the big empty field at the bottom?

Nibbler

Yes. Make a backup if you're not sure what you're doing.

lolainslacks

Did that and got this:

Quote0 row(s) affected. ( Query took 0.0017 sec )

ΑndrĂ©

What exactly have you done? If you already emptied your table or
Quote from: lolainslacks on August 28, 2010, 12:33:51 AM
changed all "2"'s to "1"'s
it's no wonder that the query affects 0 rows.