Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7029595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:33:34+00:00 2026-05-28T00:33:34+00:00

I am using mysqldump to (a) dump a table, then (b) insert it elsewhere.

  • 0

I am using mysqldump to (a) dump a table, then (b) insert it elsewhere. A problem occurs when I try to do part (b). Here is the error I get.

Duplicate entry ‘1’ for key ‘PRIMARY’

Now, hold on, hold on. I know I’m not inserting duplicate primary keys …. I checked the CREATE TABLE statement. The auto_incremement on the id field is left at the greatest value for the id column: AUTO_INCREMENT=45634650. I believe that the problem is that MySQL will give this error if you try to insert any row with an id value less than what the auto_increment value is specified at …. regardless if that id is a duplicate or not.

I tried manually removing the AUTO_INCREMENT from the TABLE CREATE statement. Same error still.

UPDATE: Here are some relevant parts of the Create table statement. Leaving out the inserts, even one of them is huge:

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
/*Table structure for table `WC_ip` */

DROP TABLE IF EXISTS `WC_ip`;

CREATE TABLE `WC_ip` (
  `id` int(11) NOT NULL AUTO_INCREMENT,

etc etc .. =)

  `activity_date` date DEFAULT NULL,
  UNIQUE KEY `userid_game_installAge` (`userid`,`game`,`install_age`),
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=45750081 DEFAULT CHARSET=latin1;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

INSERT INTO `bi_user_daily` VALUES (1,1512489,'WC','1','GR','100001229652633','asfdasdf','http://www.facebook.com/asfdasdfasdffgdf','notif','gghgf','Secondary Paid Direct','2012-01-02',0,0,0.00,0,0,0,0,194,0,0,1325491229,'Google Chrome','16.0.912.63','windows','GR','178.146.208.153',0,1325491253,24,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'incomplete',91,2,1914,2,1,3.23,0,NULL,NULL,NULL,NULL,0,'2012-01-03','2012-01-03 07:06:57','2012-01-02'),

(2,1512490,'WC','1','TW','453','asdf','http://www.facebook.com/profile.php?id=blachdfhjdfkh','dfdsfg','','Primary Paid','2012-01-02',0,0,0.00,0,0,0,0,394,0,0,1325491233,'Google Chrome','16.0.912.63','windows','TW','114.41.159.234',0,1325491258,25,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'complete',120,2,2302,2,1,6.57,0,NULL,NULL,NULL,NULL,0,'2012-01-03','2012-01-03 07:06:57','2012-01-02'),

(3,1512491,'WC','1','','1590571243','','','notif','asfd','Secondary Paid Direct','2012-01-02',0,0,0.00,0,0,0,0,0,0,0,34535,'Mozilla Firefox','9.0.1','windows','-','10.54.48.31',1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0.00,0,NULL,NULL,NULL,NULL,0,'2012-01-03','2012-01-03 07:06:57','2012-01-02')

CREATE TABLE `bi_user_daily` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userid` bigint(20) DEFAULT NULL,
  `game` varchar(45) DEFAULT NULL,
  `main.install_today` varchar(45) DEFAULT NULL,
  `main.country` text,
  `main.fbid` varchar(50) DEFAULT NULL,
  `main.photo` text,
  `main.main.url` text,
  `main.fromstr` varchar(50) DEFAULT NULL,
  `main.sourcestr` varchar(50) DEFAULT NULL,
  `main.user_type` varchar(50) DEFAULT NULL,
  `main.install_date_pst` date DEFAULT NULL,
  `main.install_hour_pst` int(11) DEFAULT NULL,
  `main.revenue_primary` int(11) DEFAULT NULL,
  `main.revenue_secondary` decimal(10,2) DEFAULT NULL,
  `main.trans_primary` int(11) DEFAULT NULL,
  `main.trans_secondary` int(11) DEFAULT NULL,
  `main.direct_installs_generated` int(11) DEFAULT NULL,
  `main.indirect_installs_generated` int(11) DEFAULT NULL,
  `main.timeplayed_total` int(11) DEFAULT NULL,
  `main.gift_sent_total` int(11) DEFAULT NULL,
  `main.monetized` int(11) DEFAULT NULL,
  `install.usercreate_time` int(11) DEFAULT NULL,
  `install.browser` varchar(75) DEFAULT NULL,
  `install.browser_version` varchar(50) DEFAULT NULL,
  `install.os` varchar(50) DEFAULT NULL,
  `install.ip_address_country` varchar(50) DEFAULT NULL,
  `install.ip_address` varchar(50) DEFAULT NULL,
  `install.noload` int(11) DEFAULT NULL,
  `install.f.reate_time` int(11) DEFAULT NULL,
  `install.load_duration` int(11) DEFAULT NULL,
  `l.f.time_saved` int(11) DEFAULT NULL,
  `l.f.playerLevel` int(11) DEFAULT NULL,
  `l.f.daysSinceInstall` int(11) DEFAULT NULL,
  `l.f.resource1` int(11) DEFAULT NULL,
  `l.f.resource2` int(11) DEFAULT NULL,
  `l.f.resource3` int(11) DEFAULT NULL,
  `l.f.resource4` int(11) DEFAULT NULL,
  `l.f.f.epairTime` int(11) DEFAULT NULL,
  `l.f.dockRepairTime` int(11) DEFAULT NULL,
  `l.f.fleetRepairTime` int(11) DEFAULT NULL,
  `l.f.maxResearchTime` int(11) DEFAULT NULL,
  `l.f.shipBuildTime` int(11) DEFAULT NULL,
  `l.f.buildingUpgradeTime` int(11) DEFAULT NULL,
  `l.f.numf.Uncovered` int(11) DEFAULT NULL,
  `l.f.attackablef.Uncovered` int(11) DEFAULT NULL,
  `l.f.numTerrainsUncovered` int(11) DEFAULT NULL,
  `l.f.numFleets` int(11) DEFAULT NULL,
  `l.f.battlesWon` int(11) DEFAULT NULL,
  `l.f.battlesTotal` int(11) DEFAULT NULL,
  `l.f.numf.ttacks` int(11) DEFAULT NULL,
  `l.f.numf.efends` int(11) DEFAULT NULL,
  `l.f.totalResourcesCombat` int(11) DEFAULT NULL,
  `l.f.totalResourcesProduced` int(11) DEFAULT NULL,
  `l.f.bubbleTimeLeft` int(11) DEFAULT NULL,
  `l.f.FBCSpend` int(11) DEFAULT NULL,
  `l.f.numFriends` int(11) DEFAULT NULL,
  `l.f.numInstallsGenerated` int(11) DEFAULT NULL,
  `l.f.numGiftsRecd` int(11) DEFAULT NULL,
  `l.f.numChatMessagesSent` int(11) DEFAULT NULL,
  `l.f.numMissionsCompleted` int(11) DEFAULT NULL,
  `l.f.numAdvancedResearched` int(11) DEFAULT NULL,
  `l.f.numWeaponsResearched` int(11) DEFAULT NULL,
  `l.f.numArmorsResearched` int(11) DEFAULT NULL,
  `l.f.numHullsResearched` int(11) DEFAULT NULL,
  `l.summary.tutorial_status` varchar(50) DEFAULT NULL,
  `l.summary.tutorial_stage` int(11) DEFAULT NULL,
  `l.summary.user_level` int(11) DEFAULT NULL,
  `l.summary.f.points` int(11) DEFAULT NULL,
  `l.summary.f.loads` int(11) DEFAULT NULL,
  `key_metrics.logged_in` int(11) DEFAULT NULL,
  `key_metrics.timeplayed` decimal(10,2) DEFAULT NULL,
  `key_metrics.revenue` int(11) DEFAULT NULL,
  `virality.secondary_direct_install` int(11) DEFAULT NULL,
  `virality.secondary_indirect_install` int(11) DEFAULT NULL,
  `monetization.secondary_direct_revenue` decimal(10,2) DEFAULT NULL,
  `monetization.secondary_indirect_revenue` decimal(10,2) DEFAULT NULL,
  `install_age` int(11) DEFAULT NULL,
  `record_created_date` date DEFAULT NULL,
  `record_created_datetime` datetime DEFAULT NULL,
  `activity_date` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `userid_game_installAge` (`userid`,`game`,`install_age`)
) ENGINE=MyISAM AUTO_INCREMENT=45634650 DEFAULT CHARSET=latin1;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:33:35+00:00Added an answer on May 28, 2026 at 12:33 am

    I ran into this very same issue a few months ago (posted solution on my blog). There is a known issue with MySQL 5.1.11+ where if you do a mysqldump, it also outputs the auto_increment count (as you stated in your post). You can use sed (stream edit) and parse out the auto_increment construct when generating your dump file:

    mysqldump -u username -p -h <db-host> --opt <db-name> -d --single-transaction | sed 's/ AUTO_INCREMENT=[0-9]*\b//' > <filename>.sql
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to ignore certain fields of a table using mysqldump without
I am using mysql database. I am using mysqldump to create a dump of
I am using mysqldump to transfer a table from one database to another. mysqldump
I'm using mysqldump to dump all my tables to CSV files like so: mysqldump
I'm trying to generate a mysql dump file from PHP using the following: exec('mysqldump
I'm using mysqldump to replicate a database between accounts on a particular machine. Everything
How can I make a perfect backup of mysql database using mysqldump? When I
How can I run the following command using subprocess.Popen ? mysqldump database_name table_name |
I've tried using mysql dump in the command line and it worked. How do
I wanted to make mysql dump files using a batch file and an app

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.