MySQL Add admin to WordPress database

Have you ever been banned from your WordPress site? Since anything can happen and you get locked out of your page, below we will see how you can add a user (administrator) to the WordPress database via MySQL so that you can regain your access.

WordPress 4

One possible lockout scenario is a hacker deleting your admin account from the database, and another is you forgetting your password.

Of course, before we start, we should mention once again the importance of having them
backups of your database. If there are, with a restore the problem is temporarily solved for the first scenario.
I mention temporarily because in the event of an attack you should find the security gap.

How to add an admin to your WordPress database via MySQL

phpMyAdmin is a web tool and allows you to manage MySQL databases using your browser.

So if you are locked out of the WordPress admin panel for any reason, follow the steps below:

simply run the 3 commands in the SQL context of your database as you see it through the phpMyAdmin tool

INSERT INTO `databasename`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('3','demo', MD5('demo'), 'Your Name','','','2022-09-11 00:00:00', '', '0', 'Your Name'); INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '3', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}'); INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '3', 'wp_user_level', '10');

Make sure you change it databasename with the name of the database you are messing with. Also, don't forget to change all other VALUES to the ones you want for the new user.

Also check if the tables prefix (wp_) is different in your database. If it is you should change it.

In the above code they are marked in yellow. The Best Technology Site in Greecefgns

mysql, wordpress, admin, iguru

Written by giorgos

George still wonders what he's doing here ...

Leave a reply

Your email address is not published. Required fields are mentioned with *

Your message will not be published if:
1. Contains insulting, defamatory, racist, offensive or inappropriate comments.
2. Causes harm to minors.
3. It interferes with the privacy and individual and social rights of other users.
4. Advertises products or services or websites.
5. Contains personal information (address, phone, etc.).