Help with a mysql database, how to reset a "unique" id to 1.

garrette

New Member
Messages
27
Reaction score
0
Points
0
As of now, the database in mysql has a unique row, named "id" which is set as auto-increment.

I was debugging the site with some fake accounts, and now I deleted them and wish to make actual accounts on the site, but the id number doesn't start at 1, it starts where it left off.

How can I restart back at 1? I don't think I can post my table information. . . but is there a function that I'm missing that willl accomplish this?
 

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
That's one way, other way:

1) PHPMyAdmin. Select the database.
2) Select the Table.
3) Click "Operations" at the top.
4) Look for "Auto_Increment", which will have a text field after it with a number.
5) Set that number to 1.
6) Click Go.

Done, without having to erase/remake the table.
 

garrette

New Member
Messages
27
Reaction score
0
Points
0
That's one way, other way:

1) PHPMyAdmin. Select the database.
2) Select the Table.
3) Click "Operations" at the top.
4) Look for "Auto_Increment", which will have a text field after it with a number.
5) Set that number to 1.
6) Click Go.

Done, without having to erase/remake the table.

Thankyou, very helpful.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
You can also use ALTER TABLE:
Code:
ALTER TABLE `table` AUTO_INCREMENT=1;

The same statement can be used to change any of the table options. For example:
Code:
ALTER TABLE `table` Engine=InnoDB;
ALTER TABLE `table` Comment='A comment';
 
Top