n0sleeves Posted June 3, 2014 Share Posted June 3, 2014 Okay, before I say anything, I know I should be using Git. Yes. It would make my life easier, but I really don't want to right now. Plus, I want to use a new database instead of messing up the original. So, with that said: I have project 1 folder (contains active PW and site files). I exported the database and duplicated the folder. When I went to import the exported database into the newly created one, I get this error:#1062 - Duplicate entry '2' for key 'PRIMARY' Wtf? I thought it would be simple to just backup / import. Guess not I am not a SQL experienced user so I am lost. Tried googling but answers are too complicated. Help please Link to comment Share on other sites More sharing options...
DaveP Posted June 3, 2014 Share Posted June 3, 2014 How did you export the database? Give us a quick description of the steps you took to export & import, with any tools used. Link to comment Share on other sites More sharing options...
n0sleeves Posted June 3, 2014 Author Share Posted June 3, 2014 How did you export the database? Give us a quick description of the steps you took to export & import, with any tools used. Using Wamp and PhpMyAdmin (Version information: 4.0.4) MySQL server (Server version: 5.6.12-log) Here's the steps I do: Select project_v1 database (the original database). Choose Export > Quick Export > SQL Format File saved Created a new database called project_v2, then select it Choose Import > I select previous exported file > Leave it on all default Settings Then this error pops up when I hit Go: Error SQL query: -- -- Dumping data for table `fieldgroups` -- INSERT INTO `fieldgroups` ( `id` , `name` ) VALUES ( 2, 'admin' ) , ( 3, 'user' ) , ( 4, 'role' ) , ( 5, 'permission' ) , ( 1, 'home' ) , ( 88, 'sitemap' ) , ( 83, 'basic-page' ) , ( 80, 'search' ) , ( 97, 'album' ) , ( 98, 'artist' ) , ( 99, 'artists' ) , ( 100, 'track' ) , ( 101, 'catalog' ) , ( 102, 'genres' ) , ( 103, 'genre' ) , ( 104, 'moods' ) , ( 105, 'mood' ) , ( 106, 'full-width' ) ; MySQL said: Documentation #1062 - Duplicate entry '2' for key 'PRIMARY' Link to comment Share on other sites More sharing options...
cstevensjr Posted June 3, 2014 Share Posted June 3, 2014 What happens when you go to your new database in PHPMyAdmin, under the "Structure" tab and click "Check All" and change "with selected" to "Drop" and then press "Go", then try the database import again? Link to comment Share on other sites More sharing options...
3fingers Posted June 3, 2014 Share Posted June 3, 2014 It looks like you're importing your db after a new installation of processwire, which has just set some primary keys (ids) and so it gaves you an error when you're trying to overwrite them (at least I'm guessing so). Try to import your db before installing pw, skip it and then try to go to yoururl/processwire (or any admin url you've set). Just my two cents. 2 Link to comment Share on other sites More sharing options...
n0sleeves Posted June 3, 2014 Author Share Posted June 3, 2014 What happens when you go to your new database in PHPMyAdmin, under the "Structure" tab and click "Check All" and change "with selected" to "Drop" and then press "Go", then try the database import again? The new database is empty and doesn't show that. It looks like you're importing your db after a new installation of processwire, which has just set some primary keys (ids) and so it gaves you an error when you're trying to overwrite them (at least I'm guessing so). Try to import your db before installing pw, skip it and then try to go to yoururl/processwire (or any admin url you've set). Just my two cents. When I copied the project folder to a new folder, I also copied Processwire with it. No new installation. Link to comment Share on other sites More sharing options...
DaveP Posted June 3, 2014 Share Posted June 3, 2014 Hmm, cstevensjr and 3fingers have covered exactly the ground likely to cause these issues. Having googled around, and please forgive me for suggesting this, are you absolutely sure that you are importing the db structure into the new db and not the old one? The reason I ask is that that is one way to guarantee duplicate keys, because they would of course already exist. (And we do all do things like that occasionally.) Link to comment Share on other sites More sharing options...
n0sleeves Posted June 3, 2014 Author Share Posted June 3, 2014 Hmm, cstevensjr and 3fingers have covered exactly the ground likely to cause these issues. Having googled around, and please forgive me for suggesting this, are you absolutely sure that you are importing the db structure into the new db and not the old one? The reason I ask is that that is one way to guarantee duplicate keys, because they would of course already exist. (And we do all do things like that occasionally.) No offense taken. Yes, I am positive I am importing the old, exported, original database into the new, blank and empty db. I even created yet another db with a different name to see if that was the problem and still throwing the same error :/ Link to comment Share on other sites More sharing options...
n0sleeves Posted June 4, 2014 Author Share Posted June 4, 2014 Any other ideas? I want to start working on the new version as soon as possible, but can't until I get this working Link to comment Share on other sites More sharing options...
adrian Posted June 4, 2014 Share Posted June 4, 2014 Not sure how it could possibly have happened, but have you checked through the SQL file to make sure that: INSERT INTO `fieldgroups` ( `id` , `name` ) is not duplicated anywhere. Link to comment Share on other sites More sharing options...
muzzer Posted June 5, 2014 Share Posted June 5, 2014 Can you post the first page of the SQL you are trying to import Link to comment Share on other sites More sharing options...
n0sleeves Posted June 5, 2014 Author Share Posted June 5, 2014 Not sure how it could possibly have happened, but have you checked through the SQL file to make sure that: INSERT INTO `fieldgroups` ( `id` , `name` ) is not duplicated anywhere. If by "not duplicated" you mean (only showing once), then yes, it only appears once in the SQL file. Can you post the first page of the SQL you are trying to import Sorry, my limited noob knowledge does not understand what constitutes pages I have one SQL file. Would you like to see the complete contents of it (it's pretty long)? Link to comment Share on other sites More sharing options...
3fingers Posted June 5, 2014 Share Posted June 5, 2014 Ok @n0sleeved, I think I got the solution Here in my office I got your same setup and, following the exact same procedure you mention, I recieve the error MySql gave you. To solve this I've choosen not to export through the "Rapid" option, and go for the "Custom" one. In the options panel I have then checked: Add instruction DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT and exported leaving all the rest with default values. It worked! Let us know! 5 Link to comment Share on other sites More sharing options...
n0sleeves Posted June 5, 2014 Author Share Posted June 5, 2014 Ok @n0sleeved, I think I got the solution Here in my office I got your same setup and, following the exact same procedure you mention, I recieve the error MySql gave you. To solve this I've choosen not to export through the "Rapid" option, and go for the "Custom" one. In the options panel I have then checked: Add instruction DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT and exported leaving all the rest with default values. It worked! Let us know! That worked!!!!!!! OMG - THANK YOU @3fingers! Thanks for all the other replies as well guys. It's so nice to have this forum where people are so willing to help each other. In all my experience using other "forums" across various websites, this one has proven to be the most helpful, friendly, and open. The fact, that we all use Processwire makes it even better. Now I can finally get back to working on this site. 1 Link to comment Share on other sites More sharing options...
maxdev974 Posted February 20 Share Posted February 20 On 6/5/2014 at 12:52 PM, 3fingers said: Ok @n0sleeved, I think I got the solution Here in my office I got your same setup and, following the exact same procedure you mention, I recieve the error MySql gave you. To solve this I've choosen not to export through the "Rapid" option, and go for the "Custom" one. In the options panel I have then checked: Add instruction DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT and exported leaving all the rest with default values. It worked! Let us know! your solve is still up to date! It save my time a lot! Thx! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now