Manual:User groups table

The user_groups table maps the users in a particular MediaWiki installation to their corresponding man>Special:MyLanguage/Manual:User rights|user rights.

Each group can be assigned a mixture of permissions through  or via extensions; all users of a particular group have those permissions granted to them as a result of their membership in the group.

As the table is separate from the  table, this allows for the creation of a shared user database with permissions that vary from wiki to wiki within a wiki farm.

This table was introduced on r5648, in MediaWiki 1.5.

If you are using MediaWiki 1.3 or 1.4, have a look at .

Before MediaWiki 1.5, user rights were stored in the the  field of the  table.

All unregistered users automatically belong to the   group and only to that group; all registered users additionally are automatically part of the  </> group.

User groups are additive; as a result, all registered users have all the privileges assigned to the <tvar|code> </> group as well.

Formerly there was a "sysop bit"; now, making a user a sysop adds a row to <tvar|groups> </>.

Implicit group memberships and AutoPromote>Special:MyLanguage/Manual:$wgAutopromote</>|auto-promoted groups such as *, user, or autoconfirmed are not stored in this table. To retrieve all effective groups use <tvar|getEffectiveGroups></>.

ug_user
This field links to a given user's <tvar|id></>.

It is a foreign key used to link accounts with their assigned privileges.

ug_group
This field stores the user's permissions, which are stored as groups.

At runtime, <tvar|GroupPermissions></> will associate group keys with particular permissions; a user will have the combined permissions of any group they're explicitly in, plus the implicit <tvar|code> </> and <tvar|user> </> groups.

Example <tvar|group> </> values: 'bot', 'bureaucrat', 'sysop'.

There is one row for each (explicit) group the user is in.

ug_expiry
This field stores a user group's expiry time.

It is similar to pr_expiry in the page restrictions table and ipb_expiry in the ipblocks table.

Schema summary
<tt>DESCRIBE user_groups;</tt> +---+--+--+-+-+---+ +---+--+--+-+-+---+ +---+--+--+-+-+---+
 * Field    | Type             | Null | Key | Default | Extra |
 * ug_user  | int(11) unsigned | NO   | PRI | 0       |       |
 * ug_group | varbinary(255)   | NO   | PRI | NULL    |       |
 * ug_expiry | varbinary(14)   | YES  |     | NULL    |       |

<tt>DESCRIBE user_groups;</tt> +--+--+--+-+-+---+ +--+--+--+-+-+---+ +--+--+--+-+-+---+
 * Field   | Type             | Null | Key | Default | Extra |
 * ug_user | int(11) unsigned | NO   | PRI | 0       |       |
 * ug_group | varbinary(255)  | NO   | PRI | NULL    |       |

<tt>DESCRIBE user_groups;</tt> +--+--+--+-+-+---+ +--+--+--+-+-+---+ +--+--+--+-+-+---+
 * Field   | Type             | Null | Key | Default | Extra |
 * ug_user | int(11) unsigned | NO   | PRI | 0       |       |
 * ug_group | varbinary(32)   | NO   | PRI | NULL    |       |

<tt>DESCRIBE user_groups;</tt> +--+--+--+-+-+---+ +--+--+--+-+-+---+ +--+--+--+-+-+---+
 * Field   | Type             | Null | Key | Default | Extra |
 * ug_user | int(11) unsigned | NO   | PRI | 0       |       |
 * ug_group | varbinary(16)   | NO   | PRI | NULL    |       |

<tt>DESCRIBE user_groups;</tt> +--+-+--+-+-+---+ +--+-+--+-+-+---+ +--+-+--+-+-+---+
 * Field   | Type            | Null | Key | Default | Extra |
 * ug_user | int(5) unsigned | NO   | PRI | 0       |       |
 * ug_group | char(16)       | NO   | PRI | NULL    |       |

Default MediaWiki groups
In a default MediaWiki installation, ug_group can be one of the following:

<tt>query: SELECT DISTINCT `ug_group` FROM `user_groups`;</tt> ++ ++ ++
 * ug_group  |
 * bot       |
 * bureaucrat |
 * sysop     |