ARTICLE AD BOX
You need to remove shares as your PRIMARY KEY OR UNIQUE_KEY
ALTER TABLE [table name] AUTO_INCREMENT = 1 When you execute the insert command you have to skip this key.
8,1601 gold badge22 silver badges38 bronze badges
Use SHOW CREATE TABLE your-table-name to see what column is your primary key.
I solved it by changing the "lock" property from "shared" to "exclusive":
ALTER TABLE `table` CHANGE COLUMN `ID` `ID` INT(11) NOT NULL AUTO_INCREMENT COMMENT '' , LOCK = EXCLUSIVE;6,18110 gold badges45 silver badges85 bronze badges
What is the exact error message? #1062 means duplicate entry violating a primary key constraint for a column -- which boils down to the point that you cannot have two of the same values in the column. The error message should tell you which of your columns is constrained, I'm guessing "shares".
Probably this is not the best of solution but doing the following will solve the problem
Step 1: Take a database dump using the following command
mysqldump -u root -p databaseName > databaseName.dbfind the line
ENGINE=InnoDB AUTO_INCREMENT="*****" DEFAULT CHARSET=utf8;Step 2: Change ******* to max id of your mysql table id. Save this value.
Step 3: again use
mysql -u root -p databaseName < databaseName.dbIn my case i got this error when i added a manual entry to use to enter data into some other table. some how we have to set the value AUTO_INCREMENT to max id using mysql command
The DB I was importing had a conflict during the import due to the presence of a column both autoincrement and primary key.
The problem was that in the .sql file the table was chopped into multiple "INSERT INTO" and during the import these queries were executed all together.
MY SOLUTION was to deselect the "Run multiple queries in each execution" on Navicat and it worked perfectly
I had this error from mySQL using DataNucleus and a database created with UTF8 - the error was being caused by this annotation for a primary key:
@PrimaryKey @Unique @Persistent(valueStrategy = IdGeneratorStrategy.UUIDSTRING) protected String id;dropping the table and regenerating it with this fixed it.
@PrimaryKey @Unique @Persistent(valueStrategy = IdGeneratorStrategy.UUIDHEX) protected String id;2 Comments
Where did you read that he's using Java and Spring?
2023-02-04T00:16:38.25Z+00:00
Explore related questions
See similar questions with these tags.

