go into operations and set the number for auto-increment to be higher than your highest term_id (click on term_id until the highest numbers are at the top (0 being the lowest), you’ll have the number).
You should try ALTER TABLE wp_terms AUTO_INCREMENT = 1 then. Please note that it will set auto increment to 1, which means that you will need to re-enter every term you have in that table or any other term and taxonomy related tables. It will probably break the connections. Safest way would be to delete all the terms and taxonomies from admin area and then run this code in SQL from phpMyAdmin. Repeat this code with every table related to taxonomies and terms (just change the table name in code)
Problem 1: wp_terms, wp_termmeta and wp_term_taxonomy all had their ID’s set not to AUTO_INCREMENT.
Solution: ALTER TABLE table_name AUTO_INCREMENT = increment_number
- This sets
AUTO_INCREMENT
manually to a selected number increment_number
value must be at least one number higher than your current highest number of that table’s primary key that is auto incremeted- Also, don’t forget to change
table_name
Other way would be to use the same code: ALTER TABLE wp_terms AUTO_INCREMENT = X but take the highest ID in wp_terms table, add 1 to it (e.g highest ID is 83, add 1 to it and you get 84) replace the X with that value (84 in our example). Do not forget to backup your database if data is important!
wp_terms
, wp_termmeta
and wp_term_taxonomy
all had their ID’s set not to AUTO_INCREMENT
.
wp_terms AUTO_INCREMENT not set
their ID’s set not to AUTO_INCREMENT.
my case 541
ALTER TABLE 2xpwp_terms AUTO_INCREMENT = 543;
ALTER TABLE 2xpwp_termmeta AUTO_INCREMENT = 1419;
ALTER TABLE 2xpwp_term_taxonomy AUTO_INCREMENT = 542;
MySQL returned an empty result set (i.e. zero rows). (Query took 0.0107 seconds.)
ALTER TABLE 2xpwp_terms AUTO_INCREMENT = 542;
MySQL returned an empty result set (i.e. zero rows). (Query took 0.0428 seconds.)
ALTER TABLE 2xpwp_termmeta AUTO_INCREMENT = 1419;
Nothing changed
wp_terms, wp_termmeta and wp_term_taxonomy all had their ID’s set not to AUTO_INCREMENT
Manually by php my admin table structure
1.backup 3 tables wp_terms, wp_termmeta and wp_term_taxonomy
2. click on table structure of you notice extra with no “Auto increment” click on change
3. and tick the A_I auto increment as show in below image.
ALTER TABLE wp_terms AUTO_INCREMENT = 1
ALTER TABLE `2xpwp_terms` CHANGE `term_id` `term_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT;
Query error:
#1062 – ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry ‘542’ for key ‘PRIMARY’
#1062 – ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry ‘541’ for key ‘PRIMARY’
object cache eabled
cleanup SELECT * FROM `wp_term_relationships` not did anthinhg
Orphaned relationships
Maually add tags in wordpress phpmyadmin worked
insert in php my admin nit relecting tags or cats
INSERT INTO `2xpwp_terms` (`term_id`, `name`, `slug`, `term_group`) VALUES (‘542’, ‘faculty jobs’, ‘faculty’, ‘0’)
wp terms table columns
term_id`, `name`, `slug`, `term_group
wp_term_taxonomy colums
- term_taxonomy_id: A unique ID for the term and taxonomy pair
- term_id: The ID of a term in the
wp_terms
table - taxonomy: The taxonomy in which the term resides
- description
- Parent
- count
INSERT INTO `2xpwp_term_taxonomy` (`term_taxonomy_id`, `term_id`, `taxonomy`, `description`, `parent`, `count`) VALUES (‘542’, ‘542’, ‘post_tag’, ”, ‘0’, ‘0’);
Now tag got inserted & reflected in wordpress dashboard.
Table: wp_terms
Field | Type | Null | Key | Default | Extra |
---|---|---|---|---|---|
term_id | bigint(20) unsigned | PRI | auto_increment | ||
name | varchar(200) | IND | |||
slug | varchar(200) | MUL | |||
term_group | bigint(10) | 0 |
Table: wp_term_taxonomy
Field | Type | Null | Key | Default | Extra |
---|---|---|---|---|---|
term_taxonomy_id | bigint(20) unsigned | PRI | auto_increment | ||
term_id | bigint(20) unsigned | UNI Pt1 | 0 | ||
taxonomy | varchar(32) | UNI Pt2 & IND | |||
description | longtext | ||||
parent | bigint(20) unsigned | 0 | |||
count | bigint(20) | 0 |
wp_termmeta columns
Table: wp_termmeta
Field | Type | Null | Key | Default | Extra |
---|---|---|---|---|---|
meta_id | bigint(20) unsigned | PRI | auto_increment | ||
term_id | bigint(20) unsigned | IND | 0 | ||
meta_key | varchar(255) | YES | IND | NULL | |
meta_value | longtext | YES | NULL |
ALTER TABLE 2xpwp_termmeta AUTO_INCREMENT = 1419;
wp_term_relationships
post_id value = object_id
Field | Type | Null | Key | Default | Extra |
---|---|---|---|---|---|
object_id | bigint(20) unsigned | PRI Pt1 | 0 | ||
term_taxonomy_id | bigint(20) unsigned | PRI Pt2 & IND | 0 | ||
term_order | int(11) | 0 |
ALTER TABLE wp_termmeta MODIFY COLUMN meta_id bigint(20) unsigned NOT NULL auto_increment; ALTER TABLE wp_terms MODIFY COLUMN term_id bigint(20) unsigned NOT NULL auto_increment; ALTER TABLE wp_term_taxonomy MODIFY COLUMN term_taxonomy_id bigint(20) unsigned NOT NULL auto_increment;
1062 – ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry ‘542’ for key ‘PRIMARY’