Quantcast
Channel: Beginners Guide To CMS Fixes
Viewing all articles
Browse latest Browse all 10

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

$
0
0

Add admin via MSQL 1WordPress is a platform that makes it easy to add different users, but sometimes things happen and it is not possible to be logged into the admin dashboard. When you do not have the ability to log into your site, you need to know how to create an admin user via MySQL to gain access. Prior to editing the MySQL database, you will need to make a full backup of the database. In addition, make sure you fully understand how the phpmyadmin works.

 

Accessing the Database

Add admin via MSQL 2The first step in creating a new admin user is to locate the WordPress database. It is in your phpmyadmin database, so you need to log into it first. The changes will be made in the wp_users table and the wp_usermeta table. It is best to start with the wp_users table, because that is where you will be working with login information.

Creating a New Admin User

Add admin via MSQL 3When you are in the wp_users table, you will see different menu options labeled: browse, structure, SQL, search, Insert, etc. You are looking for the Insert option so you will have access to the ID and then user files. The different fields include an ID (simply pick a number to act as the user identification), login (the username the user will be given), pass (a password for that username), nicename (give the user a nickname), email, URL (the site’s URL), registered, and status (needs to be set as zero). After you get everything filled out, click the “go” button and you will be ready for the next step.

Setting Up the WP_usermeta Table

After you have created the user, you will need to edit the wp_usermeta table. You will find the “insert” tab when you click on this table in your phpmyadmin and be given many of the same fields. The ID you filled out in the wp_users table will be placed in the user_ID field and the unmeta_ID will be left blank.

When you come to the meta_value field, you need to insert the following code:

a:1:{s:13:”administrator”;s:1:”1”;}

Then you need to create another field with the meta_key put at the user_level. Finally, select the “go” button and watch the new user suddenly be created. You can give the login information to the person who was unable to access the dashboard via the standard method, or you can log in to the wp-admin with the user credentials you just created.

Editing the User

Once you have logged into the admin dashboard, go to the user option. Edit the username that was just created by clicking on it and then hit the save button. You will not need to actually make any changes, you just need to hit the save button, as you are giving WordPress the ability to add information to the user fields on the backend.

For developers who know SQL, it is possible to add the new admin users to the MySQL database with a few lines of code. This is best if you understand where the code goes, the code to add, and how to change the values to make sure it displays properly. It will do the same thing as the aforementioned steps, but is an expedited process.


Viewing all articles
Browse latest Browse all 10

Trending Articles