I've created a drupal website on my local server, and want to upload it to webhost (HostGator). I've done:

(1) installed Drupal (they provide 6.9)
(2) updated to 6.10 (fine)
(3) reinstated custom modules - updated fine (now modules selection identical to my local version)
- during the above I carefully followed the steps outlined in the UPGRADE.txt that came with 6.10
(4) exported local database .SQL (whs.sql)

Now, when I tried to import whs.sql, I got the error:

ErrorSQL query:--
-- Dumping data for table `actions` -- INSERT INTO `actions` (`aid`, `type`, `callback`, `parameters`, `description`) VALUES ('comment_unpublish_action', 'comment', 'comment_unpublish_action', '', 'Unpublish comment'), ('node_publish_action', 'node', 'node_publish_action', '', 'Publish post'), ('node_unpublish_action', 'node', 'node_unpublish_action', '', 'Unpublish post'), ('node_make_sticky_action', 'node', 'node_make_sticky_action', '', 'Make post sticky'), ('node_make_unsticky_action', 'node', 'node_make_unsticky_action', '', 'Make post unsticky'), ('node_promote_action', 'node', 'node_promote_action', '', 'Promote post to front page'), ('node_unpromote_action', 'node', 'node_unpromote_action', '', 'Remove post from front page'), ('node_save_action', 'node', 'node_save_action', '', 'Save post'), ('user_block_user_action', 'user', 'user_block_user_action', '', 'Block current user'), ('user_block_ip_action', 'user', 'user_block_ip_action', '', 'Ban IP address of current user'),[...] (more coming)

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

I dropped and recreated that table, restarted the Import, then got error:

"SQL query:

-- -- Dumping data for table `blocks` -- INSERT INTO `blocks` (`bid`, `module`, `delta`, `theme`, `status`, `weight`, `region`, `custom`, `throttle`, `visibility`, `pages`, `title`, `cache`) VALUES (1, 'user', '0', 'garland', 1, 0, 'left', 0, 0, 0, '', '', -1), (2, 'user', '1', 'garland', 1, 0, 'left', 0, 0, 0, '', 'User Access:', -1), (3, 'system', '0', 'garland', 1, -5, 'footer', 0, 0, 0, '', '', -1), (4, 'system', '0', 'a3_atlantis', 1, -3, 'footer', 0, 0, 0, '', '', -1), (5, 'user', '0', 'a3_atlantis', 1, -10, 'right', 0, 0, 0, '', '', -1), (6, 'user', '1', 'a3_atlantis', 1, -9, 'right', 0, 0, 0, '', 'User Access:', -1), (7, 'comment', '0', 'a3_atlantis', 0, -11, '', 0, 0, 0, '', '', 1), (8, 'menu', 'primary-links', 'a3_atlantis', 0, -12, '', 0, 0, 0, '', '', -1), (9, 'menu', 'secondary-links', 'a3_atlantis', 1, -7, 'left', 0, 0, 0, '', 'Highlights:', -1), (10, 'node', '0', 'a3_atlantis', 0, -10, '', 0, 0, 0, '', '', -1), (11, 'user', '2', 'a3_atlantis', 0, -9, '', 0, 0, 0[...]

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

I know (almost) nothing about SQL; having said that, I'm wondering whether it would work to simply drop all the tables and re-run the Import. Would the INSERT INTO operations first create the tables if they're not found to exist?

If not, how should I proceed?

Thanks much for your help.

Comments

Bobby1290’s picture

You have to have an empty database to be able to import, that is why you are getting the duplicate keys.

Assuming your test database was also 6.10 with the exact modules as your production server you could drop all the tables from the production database and then import the test database.

(Be sure to scan the test database and update local paths to make them just as the ones on the production server.)

As far as I know if you do a (std) export, the tables will be created.

missmobtown’s picture

Dropping the existing tables from the db I had set up on the new host turned out to be the final step in getting my migration to work!

cdavidyoung’s picture

In phpMyAdmin select the DB and at the bottom of the list of tables you can Check All. To the right of that there is a dropdown box. Select drop. Afterwards you can use import sucessfully.

John Ching’s picture

I have been having many days of headache trying to migrate the database of my site onto my localhost. I tried importing the database direct though Phpmyadmin and also through BigDump to the database of the localhost. But I kept getting the:

#1062 - Duplicate entry 'comment_unpublish_action' for key 'PRIMARY' and also numerous 'limit exceeded' whether I was importing through Phpmyadmin or using Bigdump.

The problem turned out to be something to do with the extracting (uncompressing) a sql.gz file to sql, after downloading the sql.gz. During the the extracting (I used 7 Zip) something gets corrupted in the file and makes for the 'repeat entries'.

Once I stopped trying to import using a sql file and and imported the compressed sql.gz through BigDump, the import finished successfully without incident.

I realise this comment is not as much about Drupal as about migrating a Drupal site though Phpmyadmin and BigDump. Just hoping it would save someone days of headache in a similar setup. My site Drupal 7.34.