If we have to alter or modify the primary key of a table in an existing mysql table, the following steps will help you.
For a table without primary key
For single primary key
ALTER TABLE table_name ADD PRIMARY KEY(your_primary_key);
For composite primary key
ALTER TABLE table_name ADD PRIMARY KEY(key1, key2, key3);
For a table with already existing primary key
For single primary key
ALTER TABLE table_name DROP PRIMARY KEY, ADD PRIMARY KEY(primary_key);
For composite primary key
ALTER TABLE table_name DROP PRIMARY KEY, ADD PRIMARY KEY(key1, key2, key2);
Hope this is helpful 🙂