+ Reply to Thread
Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By Livewire

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

  1. #1
    garrette is offline x10Hosting Member garrette is an unknown quantity at this point
    Join Date
    Jan 2012
    Posts
    27

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

    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?

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

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

    Drop Table.
    Create Table.
    Nothing is always absolutely so.

  3. #3
    Livewire's Avatar
    Livewire is offline Abuse Compliance Officer Livewire is a glorious beacon of lightLivewire is a glorious beacon of light
    Join Date
    Jun 2005
    Location
    Behind a keyboard.
    Posts
    8,998

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

    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 likes this.


    TOS breakers will be suspended regardless of race, creed, national origin, hair color, or favorite food. Thanks for your understanding!

  4. #4
    garrette is offline x10Hosting Member garrette is an unknown quantity at this point
    Join Date
    Jan 2012
    Posts
    27

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

    Quote Originally Posted by Livewire View Post
    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.

  5. #5
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

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

    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';
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. Replies: 0
    Last Post: 05-13-2011, 08:06 AM
  2. "General Error" MySQL database problem
    By vinas55 in forum Free Hosting
    Replies: 0
    Last Post: 01-06-2011, 05:59 AM
  3. Replies: 2
    Last Post: 05-31-2009, 11:09 PM
  4. Replies: 7
    Last Post: 12-03-2008, 07:12 PM
  5. Replies: 0
    Last Post: 12-02-2008, 03:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers