Blog

How to Create a WordPress Admin using MySql Database

There are several reasons you might want to create a WordPress administrator using database tables. For example, maybe you deleted your user role in WordPress, you may have just transferred a clients site to a new host and you need to access their site to work on some things or maybe your WordPress database was hacked and your user tables have been removed.

In any case, creating a new user administrator using your database is easy. In this quick tutorial, I’ll show you how to do just that.

* Bookmark this page or take notes, you’ll need the information here each time you create a new administrator.

Video tutorial:

Step By Step:

Before you start, you’ll need to know which database the site you’re trying to add an admin to is using. Do this by logging into your cPanel, going into your file manager and finding the folder for your WordPress site. Inside that folder, open up the wp-config.php file and find the database name. Got it? Great, let’s start the tutorial.

First, go into your phpMyAdmin:

 

Next, open the database that’s connected to your website and click on ‘wp_users’ (keep in mind that your prefix ‘wp_’ may be different. In the example below, you can see that the database is using wpt9_ as a prefix)

 

Now we need to add a new user to our database. Do this by clicking on ‘insert’ at the top while in the wp_users table and fill in the following fields:

  • user_login – Your username
  • user_pass – Enter a password and select MD5 encoding from the drop down box
  • user_nicename – Your name
  • user_email – Your email
  • user_url – Your website address (can be any website you’re associated with)
  • display_name – Your username

When you’re done filling out these fields, click ‘go

 

Now we need to find the user id number that was assigned to the new user you’ve just created. Do that by clicking on the wp_users table and finding the new user you’ve just added. You’ll see the user id under the ‘ID’ column

 

Next, we need to add the correct permissions for this users role. We’ll do this by editing the user meta. Click on the wp_usermeta table, then click on ‘insert’ at the top while in the wp_usermeta table

 

Now fill in the following fields:

  • user_id – The new user’s id
  • meta_key – wp_capabilities *remember, your prefix may be different. It’s wpt9_ in the example.
  • meta_value – a:1:{s:13:”administrator”;s:1:”1″;}

When you’re done filling out these fields, click ‘go

 

Now we’ll insert one more line. Click on ‘insert’ at the top while in the wp_usermeta table
and fill in the following fields:

  • user_id – The new user’s id
  • meta_key – wp_user_level *again, note your database prefix
  • meta_value – 10

When you’re done filling out these fields, click ‘go

The new administrator should now be able to log in.

No Comments

Leave a Reply

CONTACT ME


Do you need design work done? Do you have any questions or comments? Ask me anything, I'm here for you! Send me a message and I'll get back to you as soon as I can.







    Address:

    United States

    924 26 Road
    Grand Junction, Colorado
    81506

    Europe

    Radimovice 80
    Sychrov, Czech Republic
    46344

    Phone:

    USA and Europe
    1+(970)316-3016

    If you like what I do and would like to work together, let's have a coffee and chat. I'm open to new ideas and would love to work on your company as my next portfolio project.

    Copyright © 2017 | ClintGorman.com