Content:
Share on:

Adding Admin User in WordPress Database: A Step-by-Step Guide

February 10, 2026
Photo add admin user WordPress database

Have you ever found yourself locked out of your WordPress site, perhaps due to a forgotten password, a compromised administrator account, or even a migration gone awry? Regaining access can feel like searching for a lost key in a dark room. Fortunately, if direct login bypasses fail, you still hold a powerful key – your WordPress database. This guide will walk you through the process of adding an administrator user directly into your WordPress database, a potent, yet precise, method requiring careful execution. Think of the database as the foundational blueprint of your website; directly editing it allows you to redraw certain crucial elements.

Before you embark on this journey, it’s imperative to grasp what you’re about to interact with. Your WordPress database isn’t just a jumble of data; it’s a meticulously organized collection of tables, each serving a specific purpose. Imagine it as a filing cabinet, with each drawer representing a table and each file within containing specific pieces of information.

What is a Relational Database?

WordPress primarily utilizes a MySQL or MariaDB relational database. In a relational database, data is organized into tables, and these tables are related to each other through common fields. This structure allows for efficient storage and retrieval of information. For instance, the wp_users table contains user information, and the wp_usermeta table holds additional details about those users, linked by a common user ID.

Identifying Key WordPress Tables

For our current endeavor, two tables are of paramount importance:

  • wp_users: This table is the repository for all user accounts on your WordPress site. It stores essential details like ID, user_login (the username), user_pass (the hashed password), user_email, and user_registered. Think of this as the master roster of everyone with an account.
  • wp_usermeta: This table stores additional metadata about each user, such as their first name, last name, nickname, and, crucially for our purpose, their capabilities and roles within WordPress. This is where WordPress defines whether a user is an administrator, editor, author, or subscriber. Consider it the permissions manifest for each user.

It’s crucial to understand that the prefix wp_ is the default. Your database tables might use a different prefix (e.g., wp123_users), a security measure often employed during installation. Always verify the correct table prefix before proceeding.

If you’re looking for a comprehensive guide on managing user roles in WordPress, you might find the article on Syncfic particularly helpful. It not only covers how to add an admin user directly through the database but also delves into various user permissions and best practices for maintaining security within your WordPress site. This resource can enhance your understanding of user management and help you effectively navigate the WordPress ecosystem.

Accessing Your WordPress Database

To manipulate the database, you first need a gateway. This gateway is typically provided by your web hosting control panel.

Navigating to Your Hosting Control Panel

Most web hosts provide a control panel like cPanel, Plesk, or a custom dashboard. Your first step is to log into this panel. If you’re unsure how to access it, consult your hosting provider’s documentation or support.

Locating phpMyAdmin

Once inside your control panel, search for a tool called phpMyAdmin. phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web. It’s essentially a graphical user interface (GUI) for your database, making it much easier to interact with than command-line tools. Think of phpMyAdmin as your translator, converting complex database commands into user-friendly clickable options.

Selecting Your WordPress Database

Upon entering phpMyAdmin, you’ll likely see a list of databases on the left-hand sidebar. Each WordPress installation corresponds to a unique database. If you have multiple WordPress sites hosted, you’ll need to identify the correct database. You can usually find the database name in your WordPress wp-config.php file, located in the root directory of your WordPress installation. Open this file (via FTP or your host’s file manager) and look for the line defining DB_NAME.

Once you’ve identified the correct database, click on its name in the phpMyAdmin sidebar. This action will display all the tables within that database in the main pane.

Creating a New User Entry in wp_users

add admin user WordPress database

With your database selected and the tables laid out before you, it’s time to create the shell of your new administrator account. This involves directly inserting a new row into the wp_users table.

Understanding the wp_users Table Structure

Before inserting data, it’s beneficial to briefly examine the structure of the wp_users table. Click on the wp_users table name in phpMyAdmin (or yourprefix_users). Then, select the “Structure” tab. You’ll see column names like ID, user_login, user_pass, user_email, user_url, user_registered, user_activation_key, user_status, and display_name.

Each column has a specific data type and constraints. For example, ID is typically an auto-incrementing primary key, meaning WordPress automatically assigns a unique ID. user_pass stores the password hash, not the plain-text password.

Inserting the New User Record

  1. Navigate to the wp_users table: In phpMyAdmin, ensure you have clicked on your WordPress database and then click on the wp_users table (or yourprefix_users) in the left sidebar.
  2. Click the “Insert” tab: At the top of the table display, you’ll find several tabs such as “Browse,” “Structure,” “SQL,” and “Insert.” Click on “Insert.” This will present you with a form to add a new row of data.
  3. Fill in the fields: You’ll be presented with a form where you can input values for each column. Here’s what you need to enter:
  • ID: Leave this field empty or set it to NULL. The database will auto-assign a unique ID.
  • user_login: Choose a unique username for your new administrator. For example, newadmin. This is the username you will use to log in.
  • user_pass: This is critical. You cannot simply type your password here. WordPress stores passwords as cryptographic hashes. You need to use the MD5 function to hash your desired password.
  • In the “Function” dropdown menu next to the user_pass field, select MD5.
  • In the “Value” text box, type your desired plain-text password (e.g., MyStrongPassword123!).
  • When you execute the query, phpMyAdmin will hash MyStrongPassword123! using MD5 and store the hash.
  • user_nicename: You can enter the same as your user_login (e.g., newadmin). This is used for URLs.
  • user_email: Provide a valid email address for the administrator (e.g., admin@yourdomain.com). This is important for password resets and notifications.
  • user_url: You can leave this blank or enter your website’s URL (e.g., https://yourdomain.com).
  • user_registered: Use the CURRENT_TIMESTAMP function. In the “Function” dropdown next to this field, select CURRENT_TIMESTAMP. This records the current date and time of registration.
  • user_activation_key: Leave this blank.
  • user_status: Enter 0.
  • display_name: You can enter a friendly display name (e.g., New Administrator).
  1. Execute the insertion: Scroll to the bottom and click the “Go” button. phpMyAdmin will execute the SQL query to insert this new row. You should receive a success message.

At this point, you have a user entry, but it lacks any administrative privileges. It’s like having a uniform but no rank insignia.

Assigning Administrator Privileges in wp_usermeta

Photo add admin user WordPress database

Now you need to grant your newly created user the power of an administrator. This is achieved by inserting specific metadata into the wp_usermeta table.

Understanding wp_usermeta for User Roles

The wp_usermeta table, as mentioned, holds additional information about users. Critically, it defines their roles. WordPress stores user capabilities and roles as serialized PHP arrays within specific meta keys. For an administrator, you need to add two key entries: wp_capabilities and wp_user_level.

Retrieving the New User’s ID

Before proceeding, you need the ID of the user you just created in the wp_users table.

  1. Browse the wp_users table: Go back to the wp_users table and click the “Browse” tab.
  2. Identify the new user’s ID: Locate the row corresponding to the user_login you just created (e.g., newadmin). Note down the ID associated with this user. This is a crucial number. Let’s assume it’s 10 for this example.

Inserting the wp_capabilities Entry

Now, we’ll assign the administrator role.

  1. Navigate to the wp_usermeta table: In phpMyAdmin, click on the wp_usermeta table (or yourprefix_usermeta) in the left sidebar.
  2. Click the “Insert” tab.
  3. Fill in the fields for wp_capabilities:
  • umeta_id: Leave this empty or NULL for auto-increment.
  • user_id: Enter the ID of your new user (e.g., 10).
  • meta_key: Type wp_capabilities (note: wp_ is your table prefix, so it might be yourprefix_capabilities).
  • meta_value: This is where you specify the role. You need to enter a serialized PHP array. Copy and paste the following exactly:

a:1:{s:13:"administrator";b:1;}

This string, when unserialized by WordPress, tells the system that this user has the ‘administrator’ capability.

  1. Execute the insertion: Click “Go.”

Inserting the wp_user_level Entry

While wp_capabilities primarily defines the modern WordPress roles, wp_user_level is a legacy field still occasionally checked by some older plugins or themes. It’s good practice to include it for full compatibility.

  1. Click the “Insert” tab again (while still in the wp_usermeta table).
  2. Fill in the fields for wp_user_level:
  • umeta_id: Leave empty or NULL.
  • user_id: Enter the same ID of your new user (e.g., 10).
  • meta_key: Type wp_user_level (again, replace wp_ with your table prefix).
  • meta_value: Enter 10. This numerical value historically corresponds to the administrator level.
  1. Execute the insertion: Click “Go.”

If you’re looking to enhance your WordPress site management, understanding how to add an admin user directly in the database can be invaluable. This process allows you to regain access or create new admin accounts when needed. For further insights on optimizing your WordPress experience, you might find this related article on project planning and management helpful. It covers essential strategies that can complement your technical skills. Check it out here for more information.

Finalizing and Testing Your New Admin User

Step Action SQL Query / Detail Notes
1 Access Database Use phpMyAdmin or MySQL client to connect to WordPress database Ensure you have database credentials
2 Insert User INSERT INTO wp_users (user_login, user_pass, user_nicename, user_email, user_status, display_name) VALUES (‘newadmin’, MD5(‘password123’), ‘newadmin’, ’email@example.com’, 0, ‘New Admin’); Replace ‘wp_’ with your table prefix; password is MD5 hashed
3 Get User ID SELECT ID FROM wp_users WHERE user_login = ‘newadmin’; Note the ID for next step
4 Assign Admin Role INSERT INTO wp_usermeta (user_id, meta_key, meta_value) VALUES (USER_ID, ‘wp_capabilities’, ‘a:1:{s:13:”administrator”;b:1;}’); Replace USER_ID with actual ID; ‘wp_’ is table prefix
5 Set User Level INSERT INTO wp_usermeta (user_id, meta_key, meta_value) VALUES (USER_ID, ‘wp_user_level’, ’10’); User level 10 corresponds to admin
6 Verify Log in to WordPress with new credentials Check admin access and dashboard availability

You’ve done the hard work. The blueprint has been updated, and the new administrator has been given their credentials and authority. Now, it’s time to see if your efforts have borne fruit.

Clearing Caches (If Applicable)

If you use any caching plugins (e.g., WP Super Cache, W3 Total Cache, LiteSpeed Cache) or server-side caching, it’s a good idea to clear them. Caches can sometimes store outdated user role information, preventing your new administrator account from being immediately recognized with full privileges. Access your caching plugin settings within WordPress (if you can log in as any user) or consult your hosting provider’s documentation on how to clear server-side caches. This is like flushing your browser’s history to ensure you’re viewing the most current version of a website.

Attempting to Log In

Close phpMyAdmin and navigate to your WordPress login page (typically yourdomain.com/wp-admin).

Use the user_login and the plain-text password you defined earlier (before it was MD5 hashed) to log in.

If everything was executed correctly, you should now be logged into your WordPress dashboard with full administrative access. You will see all the administrative menus and options available.

Verifying Account Privileges

Once logged in, navigate to Users > All Users. You should see your new user listed with the role of “Administrator.” If you see any other role, it indicates an issue with the wp_capabilities or wp_user_level entries in wp_usermeta.

You can also try to perform an administrative action, such as installing a new plugin or modifying site settings, to confirm your privileges.

This meticulous process has effectively bypassed the standard WordPress user interface and directly altered the foundational data, giving you a powerful route to regain control.

If you’re looking to enhance your WordPress site by adding an admin user directly through the database, you might find it helpful to explore related topics that cover database management and user roles. For instance, understanding how to effectively manage user permissions can significantly improve your site’s security and functionality. You can read more about this in the article on how it works, which provides insights into user management and other essential features.

Important Considerations and Best Practices

While direct database manipulation is a powerful tool, it’s a double-edged sword. Accuracy is paramount, and a single typo can lead to unintended consequences. Think of it as performing surgery on your website; precision is key.

Back Up Your Database First!

This cannot be stressed enough. Always, always, always back up your entire WordPress database before making any direct modifications. This is your safety net, your undo button. If something goes wrong, you can restore your database to its previous state. Most hosting providers offer database backup tools within their control panel. Familiarize yourself with this process before touching phpMyAdmin.

Security Implications

  • Delete the temporary admin: Once you’ve regained access with your new administrator account, and ideally created a new additional robust administrator account through the WordPress dashboard, consider deleting the temporary administrator account you just created via the database. If you use it as your primary admin, be sure to set a very strong, unique password.
  • Strong Passwords: The password you chose for your new administrator account should be strong: a combination of uppercase and lowercase letters, numbers, and symbols, and of significant length. Avoid common words or easily guessable sequences.
  • Database Prefix: As noted, your table prefix might not be wp_. Always verify this in your wp-config.php file and use the correct prefix (e.g., myblog_users). Incorrect prefixes will lead to errors.
  • MD5 Hashing: Remember, MD5 is used here because it’s what older WordPress versions primarily used for password storage, and it remains compatible. Modern WordPress uses stronger hashing algorithms like bcrypt for newly created passwords through the dashboard. However, for direct database insertions, MD5 is generally sufficient to get you logged in, after which you can change the password via the WordPress dashboard, triggering the stronger hashing. If you already have a functional admin account, it is always better to add users through the dashboard as WordPress handles the hashing automatically.

Alternative Methods and Troubleshooting

  • wp-config.php Bypass: For simply resetting a known administrator’s password, you can briefly add a line to wp-config.php to auto-log in as a specific user, then remove it. This is typically a less intrusive method.
  • Forgot Password Link: If your site’s email functionality is working, the standard “Forgot Password” link on the login page is the simplest solution. This database method is for when that fails.
  • Existing Admin Account Modification: If you want to modify an existing user to become an administrator, you would locate their user_id and then insert (or update if they already exist) the wp_capabilities and wp_user_level metadata entries for that specific user_id.
  • Common Errors:
  • Incorrect Table Prefix: If you get “Table ‘databasename.wp_users’ doesn’t exist” error, your prefix is likely wrong.
  • Missing MD5 Function: If your password doesn’t work, ensure you selected MD5 from the function dropdown for user_pass.
  • Incorrect Serialized String for wp_capabilities: Even a single character misplaced in a:1:{s:13:"administrator";b:1;} will lead to your user not having admin privileges. Copy and paste it meticulously.
  • Wrong user_id: Ensure the user_id you use when inserting into wp_usermeta is exactly the ID of the user you just created in wp_users.

By following this guide meticulously and exercising caution, you can confidently navigate the WordPress database to add an administrator user, providing a reliable recourse when typical access methods are unavailable. This foundational understanding empowers you to resolve critical access issues, putting you back in command of your digital domain.

FAQs

How can I add an admin user directly through the WordPress database?

You can add an admin user by accessing your WordPress database via phpMyAdmin, navigating to the wp_users table, inserting a new user record, and then adding the appropriate capabilities in the wp_usermeta table. This involves creating a new user ID, username, password (hashed with MD5 or better), and assigning the ‘administrator’ role in usermeta.

What information is required to create a new admin user in the WordPress database?

You need to provide a unique user ID, a username, a password (hashed), an email address, and set the user role to ‘administrator’ in the wp_usermeta table by adding the meta_key ‘wp_capabilities’ with the value ‘a:1:{s:13:”administrator”;b:1;}’.

Is it safe to add an admin user via the database instead of the WordPress dashboard?

Adding an admin user via the database is safe if done carefully, especially when you cannot access the WordPress dashboard. However, it requires caution to avoid corrupting the database or creating security vulnerabilities. Always back up your database before making changes.

What tools do I need to add an admin user to the WordPress database?

You need access to your website’s database management tool, commonly phpMyAdmin, which is available through most web hosting control panels. Alternatively, you can use command-line tools like MySQL client if you have server access.

Can I reset the password of an existing admin user through the WordPress database?

Yes, you can reset an admin user’s password by updating the user_pass field in the wp_users table with a new password hashed using MD5 or a compatible hashing method. However, WordPress uses more secure hashing now, so it’s recommended to reset passwords through the dashboard or use plugins when possible.

Send us a message

    mail
    message
    Need Help?