Rule # 1 of Digital Security: Do not put the same password for everything.

Therefore, you must remember the password of your email (or emails), your mobile password, your credit card pin, your PayPal account, etc.  Assumable, right?

Well, what about those who work in this web world? Let’s add: Hosting password, Control Panel, customer emails, CMS, SSH, FTP, phpMyAdmin, etc. Now, the thing becomes complicated, right? Well, let’s multiply it by as many projects as we have.

With this panorama, and given that You haven’t come up with the big mistake of writing them down on paper available to everyone, truth? Typically, sooner or later we forget the password of, for example, WordPress. Or what is worse, for not remembering, let’s not even remember the user! Well don’t despair, here we are for a rescue!

We will assume that your intentions are good and therefore you have full access to the server. Otherwise (if you do not have access to the server), contact your system administrator.

If you are the system administrator, to create an account with Administrator permissions in WordPress you must access the MySQL console or phpMyAdmin and execute the following code:

INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('tunombreusuario', MD5('contraseñadelnuevoadmin'), 'Nombre Apellido', '[email protected]', '0');

INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');

Where you should replace:

  • Your username: Corresponds to the username you want the new administrator account to have.
  • new admin password: It will be the password of the account we are creating.

Once this is done, we will be able to access the login window of the backend and try the new credentials.

In the event that you need to create a Super Admin account, or this method has not worked for you, we invite you to continue reading the article.

  1. WordPress 2
  2. I need SuperAdmin permissions
  3. I need SuperAdmin permissions and I don’t have MySQL access

#1. WordPress V.2

In 2005, with the launch of WordPress v.2, user levels were replaced by a role system. Therefore, if you still have that version, you must run the following code in MySQL:

INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('tunombredeusuario', MD5('contraseñadelnuevoadmin'), 'Nombre Apellido', '[email protected]', '0');

INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');

INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');

Where you should replace:

  • Your username: Corresponds to the username you want the new administrator account to have.
  • new admin password: It will be the password of the account we are creating.

And as soon as you get access, we strongly recommend that you update WordPress !!! We are already in version 4.8.

#2. I need SuperAdmin permissions

In that case, we must first create a user as explained in the “You’re in a hurry”:

INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('tunombreusuario', MD5('contraseñadelnuevoadmin'), 'Nombre Apellido', '[email protected]', '0');

INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');

When we have created it we go to the table wp_sitemeta and we search the registry with the key admins. Once there we must add our user to the array, taking into account that it must be serialized.

Example:

The user that I want to add as superadmin is called “ManceRayder”, and there are already 2 superadmins called “admin” and “Laura” in the registry.

We must, therefore, change the array:

a:2:{i:1;s:5:"admin";i:2;s:5:"Laura";}

By:

a:3:{i:1;s:5:"admin";i:2;s:5:"Laura";i:3;s:11:"ManceRayder";}

Where:
a: 3 indicates the number of array elements
i: 3 indicates the position of the element within the array
s: 11 indicates the number of characters in the register

#3. I need SuperAdmin permissions and I don’t have MySQL access

In that case, there is an official script to reset a user’s password. You can find it by clicking here.

That user does not even need to have prior administrator or super administrator permissions since you can give them, later by executing the following function:

add_action( 'init', function () {
 // Cambia $user_id por la ID de usuario que quieres hacer super admin
 grant_super_admin( $user_id );
}

Did you find this entry interesting? Have we managed to solve your doubts? Help your friends as we have helped you Share it!