1 month ago I need to makes some changes on my client websites and they delete my username and their account also was not have access of administrator. On that time I have to find the solution to create the Admin User from PHPMyAdmin panel with MySQL query. It is the best solution (for situations like this) to just create a new admin user account to gain access to WP admin dashboard and fix things as needed.
In this tutorial, We will show you how you can create a new WordPress admin user account via MySQL database (without having access to your WordPress admin dashboard).
Note: You can ONLY do this if you are the site owner. You need to have access to cPanel/Control Panel of your server (comes with your hosting plan). If you don’t know the details of your cPanel login then ask your hosting provider.
Three Methods to Create WordPress Admin Users.
- Create Admin user via PHPMyAdmin.
- Create Admin User to the Database via MySQL.
- Create Admin User with functions.php via FTP.
These are the methods that with we are going to create an admin user in WordPress. Choose whichever method that you want and get the result you desired.
Create Admin user via PHPMyAdmin.
Step 1. Access Your MySQL Database
- Log into your cPanel/Control panel
- Go to “Database” section
- Click on PHPMyAdmin icon

Step 2. Go to the WP Users table
- Select your Site’s WordPress database from the list of databases in PhpMyAdmin
- Go to the WP Users table and click on the “insert” link

Step 3. Insert a New Record in the Users Table
You will need to fill in the following fields to insert a new user record:
- ID – Keep the value of this field empty (it will automatically assign the correct value for it)
- user_login – insert the username you want to use
- user_pass – add a password for the account. Select MD5 in the functions menu (Refer to the screenshot below).
- user_nicename – leave this field empty for now
- user_email – add the email address you want to use for this account.
- user_url – leave this field empty for now
- user_registered – select the date/time for when this user is registered.
- user_status – set this to 0.
- display_name – leave this field empty for now
- Click on the Go Button (you should see a success message)

You can go back to the wp_users table and browser the entries to verify that the user record has been inserted correctly (see screenshot below).

Take note of the value if the “ID” field for this newly created user (we will need this ID field’s value for the next step). In this case, the ID is 2.
Step 4) Insert User Meta Values
This is the final step where we will assign some user meta values to the user account we just created.
Go to the “wp_usermeta” table and click on the “insert” link:

Use the following values and click the “Go” button to insert the usermeta data
- unmeta_id – Leave it blank (it will be generated for you)
- user_id – This is the ID of the user we created in the previous step. For our case, it is 2.
- meta_key – Use wp_capabilities
- meta_value – Use the following value for this field:
a:1:{s:13:"administrator";s:1:"1";}
See screenshot below

All done!
You can now log into your WP site using this newly created WP User account. You can use this account to change the password of your other user accounts or delete them (if you want to).
Create Admin User with MySQL Database Query
These are the codes that will help you to create Admin User in WordPress in just a minute. If you have access of PHPMyAdmin, then go to PHPMyAdmin and simply copy these SQL queries and paste it into SQL tab.
Steps to Create Admin User with SQL Query.
- Open PHPMyAdmin, if you are not already.
- Click on the SQL tab which is located at left side of Database tab.
- Paste the following code.
- Click on Go.
- Done!
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 ('4', 'demo', MD5('demo'), 'Your Name', 'test@yourdomain.com', 'http://www.test.com/', '2011-06-07 00:00:00', '', '0', 'Your Name'); INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', '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, '4', 'wp_user_level', '10');
Remember to change the database name to the database you are working with. Also, don’t forget to change the appropriate values.
Add Admin User via FTP with Theme’s functions.php file.
Have you ever had a client need help on their WordPress site, and have FTP access, but not actually give you a WordPress account to use? Just do the following steps and you will get easy access of Admin Account of WordPress Dashboard.
Steps to Create Admin Account with Theme’s Functions.php via FTP.
- Copy the below code snippets.
- Open the current theme’s functions.php file.
- Paste these codes.
- Change the credentials that you want to include.
- Upload the functions.php file on Server via FTP.
function add_admin_acct(){ $login = 'myacct1'; $passw = 'mypass1'; $email = 'myacct1@mydomain.com'; if ( !username_exists( $login ) && !email_exists( $email ) ) { $user_id = wp_create_user( $login, $passw, $email ); $user = new WP_User( $user_id ); $user->set_role( 'administrator' ); } } add_action('init','add_admin_acct');
Done!.
If there is already an account with the username or email address specified, it will fail and not do diddly squat.