How to create an admin user in Joomla with mysql

Sometimes you badly need to get into the admin panel of the Joomla CMS, but there is no information about the users that were already created.
At the same time we have access to the database of the site. You can create a user for yourself with a few mysql commands.

First you need to look at the table prefix in the configuration.php file (in my case it is jom25_).

Joomla 2.5:

INSERT INTO `jom25_users` (`name`, `username`, `password`) VALUES ('TempAdmin', 'tempadmin', md5('password'));
INSERT INTO `jom25_user_usergroup_map` (`user_id`,`group_id`) VALUES (LAST_INSERT_ID(),'8');

Joomla 1.5:

INSERT INTO `jom15_users` (`name`, `username`, `password`, `usertype`, `gid`) VALUES ('TempAdmin', 'tempadmin', md5('password'), 'Super Administrator', 25);
INSERT INTO `jom15_core_acl_aro` VALUES (NULL, 'users', LAST_INSERT_ID(), 0, 'TempAdmin', 0);
INSERT INTO `jom15_core_acl_groups_aro_map` VALUES (25, '', LAST_INSERT_ID());

Then go to the administrator page and log in with:
Username: tempadmin
Password: password