Fortunately, there is a solution that allows you to create a new WordPress Admin user using the phpMyAdmin tool, which is typically found within your hosting cPanel account. This guide will walk you through the steps to access and edit your WordPress MySQL database tables.
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`) VALUES ('newadmin', MD5('password'), 'New Admin', 'admin@example.com', '0');
Note: Replace 'newadmin'
with your desired username and 'password'
with your preferred password.
wp_usermeta
table from the left-hand side.user_id
=
ID
, where ID
represents the ID of the newly created admin user (typically the next available number).meta_key
column is set as wp_capabilities
and click on the "Edit" button.meta_value
field, update the value to the following:REPLACE INTO `wp_usermeta` SET `meta_value` = 'a:1:{s:13:"administrator";b:1;}' WHERE `user_id` = ID AND `meta_key` = 'wp_capabilities';
By following these steps and utilizing phpMyAdmin, you can add a new admin user to your WordPress website's database, regaining access to your WP Admin Dashboard. Remember to choose a strong password for enhanced security.
If you do not have access to phpMyAdmin you can still create a new admin user by uploading the following PHP script.
<?php // Include the WordPress configuration file require_once('./wp-config.php'); // Include the WordPress core file require_once('./wp-load.php'); // Create a new admin user $username = 'newadmin'; $password = 'password123'; $email = 'admin@example.com'; // Check if the username is available if (username_exists($username)) { echo "Username already exists. Please choose a different username."; exit; } // Check if the email address is already registered if (email_exists($email)) { echo "Email address is already registered. Please choose a different email."; exit; } // Create the new admin user $user_id = wp_create_user($username, $password, $email); if (is_wp_error($user_id)) { echo "Error creating user: " . $user_id->get_error_message(); exit; } // Set the new user as an administrator $user = new WP_User($user_id); $user->set_role('administrator'); echo "New admin user created successfully!"; ?>
Upload this script to the same directory as wp-config.php, and load it from the browser by browsing to the filename you uploaded.
Make sure to adjust the values of $username, $password, and $email to your desired values for the new admin user.
Remember to remove this script from your server after running it, as leaving it accessible can pose a security risk.
WordPress is a widely popular Content Management System (CMS) that powers over 40% of all…
WordPress is a popular platform that empowers more than 60 million websites worldwide. Millions of…
In this article, we will cover ten crucial WordPress site maintenance tasks that every website…
In this blog article, we will explore the various WordPress security solutions you can implement…
Plugins are an integral part of WordPress, as they offer countless benefits and features that…
In this article, we will explore various strategies that can help you enhance your WordPress…