Many people have suggested to use slave-skip-error option etc.. but that will completely avoid the query. How do you actually continue with the query that poses the error ? Also, I could not find a good answer as to why this actully occurs and what the number "914166" indicates ? Can someone please explain ? Show asked May 23, 2016 at 13:53
RaviRavi 2,4623 gold badges17 silver badges25 bronze badges 3
Your query shows "id = 2888555" , which is probably the column MySQL is referring to. Check values for the row with id 914166 and compare it to the values you wanted to set for id 2888555. You only have to look for columns that are part of your Primary Key. The values in these columns will be identical therefore MySQL throws out an error. MySQL is basically saying:
However there shouldn't be a problem as long as all your rows have different IDs. Posting table structure and indices would allow a more specific analysis of your problem at this point. answered May 23, 2016 at 15:04
iLikeMySqliLikeMySql 7363 silver badges7 bronze badges 5 The triggered table causes the duplicate entry error. Thanks for the suggestions. answered May 26, 2016 at 8:16
RaviRavi 2,4623 gold badges17 silver badges25 bronze badges 5 Looking for guidance as to what I continue to do wrong when trying to perform a basic replication setup between a single primary and replication servers. Through several trials over the years, this has been inconsistent at best. My more recent attempt (steps) are shown below, which is a culmination from several sites, including the MariaDB support site. Goal: Use mariabackup or other recommended method to backup the database from the primary server, restore to the replication server and successfully replicate data from the primary to the replication server. Using Mariabackup to capture a backup of the data On the master server Run the following command at MySQL command prompt
WHILE THE DB IS LOCKED Run this command to backup
After the backup, run the command to prepare
NOTE Once prepare is complete, make sure to run 'unlock tables' in the MariaDB command prompt window. The prepare command will show the binlog file and position to use in CHANGE MASTER TO, so be sure to capture the output from the prepare command after it completes. Example output from prepare command
RESTORING THE DB Copy the backup directory from the master over to the root of the DB drive on the slave Log in to the slave server and open a command prompt to the backup directory Run the command to copy restore the backup to the slave data directory
Start the MariaDB service on the slave server Run the following change master to command with appropriate values Example
Start and check slave
Error upon starting replication
Given that I have flushed privileges, flushed tables, and locked the DB and THEN captures the backup, I do not understand why I continue to get duplicate key after restoring and completing the replication configuration. If someone can help me understand what I'm doing wrong, I would greatly appreciate it. How do you stop duplicates in MySQL?Note − Use the INSERT IGNORE command rather than the INSERT command. If a record doesn't duplicate an existing record, then MySQL inserts it as usual. If the record is a duplicate, then the IGNORE keyword tells MySQL to discard it silently without generating an error.
How does MySQL handle duplicate entries?How to Remove Duplicate Rows in MySQL. Option 1: Remove Duplicate Rows Using INNER JOIN.. Option 2: Remove Duplicate Rows Using an Intermediate Table.. Option 3: Remove Duplicate Rows Using ROW_NUMBER(). How we can resolve replication errors?To fix the replication error we follow the below steps.. First, we log into the MYSQL. ... . On the MySQL shell, we check the slave status. ... . For that, we stop the slave from replication, using the below command. ... . Next, we tell the slave to simply skip the invalid SQL query. ... . Again, we start the slave.. What does duplicate entry mean in MySQL?When creating a primary key or unique constraint after loading the data, you can get a “Duplicate entry for key 'PRIMARY'” error. If the data in the source database is valid and there are no any duplicates you should check which collation is used in your MySQL database.
|