DuplicateUsernames

Jump to: navigation, search

Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: DuplicateUsernames.

You may see an error message when you're upgrading to Moodle 1.8 if you have a duplicate username in your Moodle's user table. You can search for duplicate usernames in your user table with the following query:

select username,
count(username) AS instances
from PREFIX_user
group by username
having (count(username) > 1);

Note that you'll have to change PREFIX_user to whatever you call your user table, e.g. mdl_user.

If this returns a list of usernames and instances, you've somehow got duplicate username entries in your database. With any luck, you'll be able to delete or rename one of these usernames, and then the database will be able to create the index on your table. The index creation will not succeed until the query above returns zero results.

When you're in the clear, you can create the index with the following query:

CREATE UNIQUE INDEX user_mneuse_uix ON PREFIX_user (mnethostid, username);

If that succeeds, you're done!

If this fails, please file a bug report, because it's likely that something else is causing your problem.