0

I have a Drupal 7 website with only UID1 user which is root admin. I deleted previous users. Now if I create a new user, it gets UID of e.g. 74.

It should be UID 2 and so on.

Anyway, I had same problem with resetting nodes back to 1. And I did it by following this answer, but it worked only if you have no nodes. Now, I have at least one user and I don't know if that query would work for 'users'.

3
  • It works for any database table. BTW, Drupal considers user with UID 1 is always the root admin. No matter if you have recreated it.
    – Jimmy Ko
    Sep 28, 2016 at 9:59
  • So I ran the ALTER TABLE users AUTO_INCREMENT = 1; but didn't work. Sep 28, 2016 at 10:04
  • Ah...you are right. Sorry for giving wrong information. I've found the possible reason here.
    – Jimmy Ko
    Sep 28, 2016 at 10:10

1 Answer 1

1

I've found the discussion thread about the issue about why users table is not auto-increment and creating a new sequences table for that purpose.

This is NOT a full sequences API not at all but it's enough for some uses. actions_aid and simpletest_test_id , that's duplicate code not to mention it belongs to the DB layer. This patch solves that. Further work: we can reuse this for users.uid as that should not be serial because of the known problems. The postgresql folks can create a version which uses proper sequences. The mysql folks can support more than the single serial mysql allows -- like a timestamp and a serial. Sorry for the hasty writeup.

In your case, you just update the value in sequences table to 1.

AND

You need to run ALTER TABLE sequences AUTO_INCREMENT = 1 as well.

2
  • I did that. But it resets back to 83 when creating new user. Sep 28, 2016 at 10:39
  • You need to alter sequences table to start from 1. Please check the updated answer.
    – Jimmy Ko
    Sep 28, 2016 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.