are two different commands. The first might work, but you still run the risk of the primary key constraint still be unsatisfied if other data elements have duplicate keys. You should, without deleting anything, be able to rung the “alter table” command and get where you are trying to go. After that, deleting the item with the ‘0’ primary key should solve the problem.
I was unable to run the alter command w/o deleting the Primary key = 0. It gave the same error, regarding duplicate Primary key.
This error seemed to be on all my tables, here is what I ran
MariaDB [survey]> delete from bsurvey_cdrs where id = "0";
Query OK, 1 row affected (0.00 sec)
MariaDB [survey]> alter table bsurvey_cdrs modify id int auto_increment;