There may be some cases where you need to create wordpress users via PHPMyAdmin. For an example, if someone hacked your site and deleted your administrator accounts from the database, you’ll not have an option to access your site any more. But if you still have access to PHPMyAdmin, you can create an administrator user via PHPMyAdmin and can access the site again. In this article we will guide you step by step on how to create an admin user to wordpress via PHPMyAdmin
Important: We highly encourage you to get a database backup before you make any edit to MySQL database.
Create a WordPress User
Ok, first you need to login to your cpanel and open PhpMyAdmin and locate the database which you have used for the wordpress site. Once you have selected the respective database, we are going to make changes to wp_users and wp_usermeta ( I assumed that you have used wp_ as the database prefix which is the default one )tables. Lets go ahead and click on wp_users.
Well, It is time to add new users information. Go ahead and click on the “Insert” tab like the above image shows by highlighted. Here are the details you got-to insert,
- ID – This is set to auto increment, so we don’t want to worry about it. Leave it as blank.
- user_login – The username you need to use when login to wordpress admin area.
- user_pass – The password you are going to use to login to wordpress admin area. Make sure to select MD5 as the function ( Screenshot bellow is clearly spotted it ).
- user_nicename – Just a nickname or something which you would like to refer yourself as.
- user_email – The email address which you like to associate with the account. You can use this email address to reset your password if you lost your password.
- user_url – The URL to wordpress user’s website.
- user_registered – The date/time which the user registered. It is ok to leave this as it is.
- user_status – set this to 0.
- display_name – This is the name which will show in wordpress dashboard when you are logged into admin area.
Here is how I filled the form roughly.
Fill the form above like demonstrated above and hit on “Go” button at the bottom right.
Set privileges to make the user an Administrator.
Well, we have inserted all the raw details for the new user, But we should set him privileges and assign him a role. We are going to edit “wp_usermeta” table to facilitate that.
Before we insert/set privileges on “wp_usermeta” we will have to get the user id which we inserted above. To do that click on the “wp_users” table and you will see a list of existing users there. Find the user you inserted above ( this is the last entry of the table ) and get the “id” value of it. Then we can move to set privileges to that user.
Click on “wp_usermeta” on tables list on the right hand side and click on “Insert” to insert an entry to the table. On that table, you are going to insert following information.
- unmeta_id – value for this field is set to auto generate. So best to leave it as blank
- user_id – This is the id value of the wp_user table for the user we inserted above. So, you know it already and insert it here.
- meta_key – set this to wp_capabilities
- meta_value – this is the value of capabilities. WordPress use this as a serialized array of privileges. Se this value to :
There are few another details to be set on the same table. So, click on “Insert” again and fill the form with following information.
- unmeta_id – leave it as blank
- user_id – set the respective user id.
- meta_key – this should be wp_user_level
- meta_value – 10
That’s it. You have created a new user with administrator privileges. You should be able to login to wp-admin using the user you created above. Thank you for reading this article. Please share your feedback with us so we can improve future articles.