After many rows are deleted, an auto-increment ID column has gaps (1, 2, 7, 8, 20…). /go/reid closes the gaps by giving every row a new ID, counting up from 1 with no gaps. /go/reid rebuilds the ID column of one table. It: Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.
Quick start
# Renumber the ID column of the "orders" table in the "shop" database
/go/reid shop orders
Options
| Argument | Required | Default | Notes |
|---|---|---|---|
<database> |
Yes | — | The MariaDB/MySQL database name, as shown by SHOW DATABASES. |
<table> |
Yes | — | The table to renumber. Its first column must be the ID. |
Examples
# Check the table's columns and keys first. The first column listed must be the ID.
mariadb -uroot -p -e "DESCRIBE shop.orders;"
# Back up the table, then renumber it
mariadb-dump -uroot -p shop orders > /root/shop-orders.sql
/go/reid shop orders
# Confirm the result
mariadb -uroot -p -e "SELECT MIN(id), MAX(id), COUNT(*) FROM shop.orders;"
After a successful run, MAX(id) equals COUNT(*).
Output
| Outcome | What you get |
|---|---|
| Table found | Re-sorting <column> Column in <table> (<database> Database)... |
| Table not found, or the check query failed | Table <database>.<table> doesn't exist. and exit status 1. |
| A step fails | The MariaDB error message. The command does not check for it and does not stop. |
| Finished | No message. |
Notes on the output:
- There is no success message. If you see no error after the
Re-sortingline, both steps ran. Table ... doesn't exist.is printed for any failure of the first query, including a wrong password inconfig.phpor MariaDB being down, because the real error is hidden.- Every run is logged with a timestamp and its arguments to
/var/log/go/reid.log.
See the full reference at /go/reid and the GoAdmio command index.
GoAdmio is free and open source, with no license fees and no account limits. Read the GoAdmio docs, or see why it is a free cPanel alternative at goadmio.com.
