1,删除原有主键:
ALTER TABLE `table_name` DROP `id`;
2,添加新主键字段:
ALTER TABLE `table_name` ADD `id` INT NOT NULL FIRST;
3,设置新主键:
ALTER TABLE `table_name` MODIFY COLUMN `id` INT NOT NULL AUTO_INCREMENT,ADD PRIMARY KEY(id);
ALTER TABLE `table_name` DROP `id`;
ALTER TABLE `table_name` ADD `id` INT NOT NULL FIRST;
ALTER TABLE `table_name` MODIFY COLUMN `id` INT NOT NULL AUTO_INCREMENT,ADD PRIMARY KEY(id);