How to Add an Admin User to the WordPress Database via MySQL

[easy-social-share counters=0 style="button"]

Most important, you will need to login to phpMyAdmin or identify your WordPress database. ( Below is a screenshot of a HostGator cPanel )

When you are in, we can easily be creating adjustments to the wp_users or wp_usermeta tables. We will just do it and click wp_users table.

We will need to add our new admin user’s information, so that click the Add tab like this displays in the picture above. In the add form, insert the following:

  • ID – choose a good number ( in our example of this , we can using the number 4 ).
  • user_login – add the username you would like to use to access the WordPress Dashboard.
  • user_pass – insert a password on this username. Make sure to select MD5 in the functions menu ( Refer to the screenshot below ).
  • user_nicename – put a nickname and something else that you would like to refer yourself as.
  • user_email – add the e-mail you would like to associate with this account.
  • user_url – this would be the url to your web site.
  • user_registered – choose the date/time for when this user is registered.
  • user_status – set this to 0.
  • display_name – put the name you like to show for this user on the site ( it can be your user_nicename value as well ).

Click the Go Key


Next we are going to have to add the values to wp_usermeta table. Click on the wp_usermeta table and then click on the Insert tab just like the previous step. Then add the following information to the insert form:

  • unmeta_id – leave this blank ( it will be auto-generated )
  • user_id – this will be the id of the user you created in the previous step. Remember we picked 4.
  • meta_key – this should be wp_capabilities
  • meta_value – insert this: a:1:s:13:”administrator”;s:1:”1″;
  • Add different row with the following information:
  • unmeta_id – leave this blank ( it will be auto-generated )
  • user_id – this will be the id of the user you created in the previous step. Also remember we chosen four.
  • meta_key – this will be wp_user_level
  • meta_value – ten

And then click the Go key, so you are creating by yourself a brand new username. Right now you need to be manage to login to your wp-admin with the username orpassword you specified in this user. At the time logged in, click Users or manage the username you simply created. Go down or click the Save key ( you don’t need tochange any-thing ). That will allow WordPress to go through and then insert some other information or cleaning up the user we just simply added.

SQL query

For developers who would like to speed using this method up , you can also easily drop this SQL query in your database .

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', '', '', '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');

Make sure you adjust the databasename to the database you are always working with . As well as don’t forget to modify the appropriate values .

Submit a comment

Pin It on Pinterest