Add WordPress Admin User in phpMyAdmin
This guide shows you how to create a new WordPress administrator account directly in phpMyAdmin, which is useful when you’re locked out of your site or need to add an admin without using the dashboard. You’ll manually insert a row into the WordPress users table and link it to the usermeta table. You’ll need access to your hosting control panel (like cPanel) and phpMyAdmin, plus your WordPress database credentials.
What You’ll Need
- Access to your web hosting control panel (e.g., cPanel, Plesk) or a tool that lets you open phpMyAdmin.
- Your WordPress database name and prefix (the default prefix is
wp_). - A text editor to prepare the SQL query (optional but recommended).
- Your site’s URL and a valid email address for the new admin.
Step-by-Step
- Log in to phpMyAdmin. Open your hosting control panel, find the phpMyAdmin icon (often under Databases), and click it. If you use a managed WordPress host, look for a “Database” or “phpMyAdmin” link in your account dashboard.
- Select your WordPress database. In the left sidebar, click the database name that holds your WordPress tables. Usually it’s something like
yourusername_wpordb_name. If you’re unsure, check yourwp-config.phpfile for theDB_NAMEconstant. - Identify your table prefix. Look at the table list. The default prefix is
wp_, so you’ll seewp_usersandwp_usermeta. If you see a different prefix (likeblog_), use that prefix in all queries. - Open the users table. Click the table that ends with
_users(e.g.,wp_users). This table stores each user’s login, email, and password hash. - Click the “Insert” tab. At the top of the screen, you’ll see tabs like Browse, Structure, SQL, and Insert. Click Insert.
- Fill in the user fields. You’ll see columns like
ID,user_login,user_pass,user_email, etc. LeaveIDempty (it auto-increments). Foruser_login, enter the username you want (e.g.,newadmin). Foruser_pass, you need a hashed password. The simplest way is to use a pre-generated MD5 hash of your password (see Tips). In theuser_emailfield, put a valid email. Setuser_registeredto the current date and time (use the format2025-01-01 12:00:00). Leave other fields as default or empty. - Generate a password hash. If you don’t have a hash, go to the SQL tab and run this query to generate one (replace
yourpasswordwith your actual password):SELECT MD5('yourpassword');
Copy the result (a 32-character string). This is the MD5 hash. Paste it into theuser_passfield. - Insert the user row. Click the Go button at the bottom. phpMyAdmin will run the INSERT query. You should see a success message. Note the new user’s ID (you can find it by browsing the
wp_userstable). - Open the usermeta table. Click the table that ends with
_usermeta(e.g.,wp_usermeta). This table stores user metadata like capabilities. - Add the administrator capability. Click the Insert tab again. You need to add a row with:
umeta_id: leave empty (auto-increment).user_id: the ID of the new user you just created (e.g., 5).meta_key:wp_capabilities(use your actual prefix, e.g.,wp_capabilities).meta_value:a:1:{s:13:"administrator";b:1;}(this is a serialized array that grants the administrator role).
Click Go.
- Add the user level (optional but recommended). Insert another row in
wp_usermetawith the sameuser_id,meta_keyaswp_user_level, andmeta_valueas10. This sets the user level to 10 (the highest). - Test the login. Go to your WordPress login page (e.g.,
yoursite.com/wp-login.php) and log in with the new username and password. You should have full admin access.
Common Mistakes
- Using the wrong table prefix. If you use
wp_but your site uses a different prefix, the user won’t be recognized. Always check the actual table names. - Forgetting to add the capabilities row. Without
wp_capabilities, the user exists but has no role, so they can’t access the admin dashboard. - Using a plain text password. WordPress requires a hashed password. Using MD5 is acceptable for a manual insert, but WordPress will rehash it on next login. Never put a plain password in the database.
- Incorrect serialized data. The
meta_valuefor capabilities must be exactlya:1:{s:13:"administrator";b:1;}. A typo or wrong string will cause the role to not apply. - Not setting the user_registered field. Some plugins or themes may expect a valid date. If left as 0000-00-00, it can cause errors.
Tips
- Use a strong password. Since you’re manually creating the hash, choose a long, unique password. You can generate an MD5 hash using online tools or the SQL query mentioned above.
- Back up your database first. Before making changes, export your database from phpMyAdmin (Export tab) so you can restore if something goes wrong.
- Use the correct prefix in meta_key. If your prefix is
wp_, the meta_key iswp_capabilities. If your prefix ismy_, it’smy_capabilities. - After logging in, change your password. Go to Users > Your Profile and set a new password. This ensures WordPress uses its proper hashing algorithm.
- Consider using a plugin instead. If you have any access to the dashboard, plugins like “Add Admin” can do this safely without touching the database.
Troubleshooting
- Login fails with “Invalid username or password.” Double-check the username and password hash. Try re-inserting the user row with a fresh MD5 hash. Also ensure the email is correct.
- You can log in but see no admin menu. This means the capabilities row is missing or incorrect. Go back to
wp_usermetaand verify themeta_keyandmeta_valueexactly as shown. - Error: “You do not have sufficient permissions.” This usually indicates the user role isn’t set. Re-add the
wp_capabilitiesrow with the administrator value. - The user appears in the database but can’t log in. Check that the
user_statusfield is set to 0 (active). If it’s 1, the account is disabled. - After login, the site redirects to install.php. This happens if the database prefix is wrong or the
wp_userstable is empty. Make sure you inserted into the correct database and table. - PHPMyAdmin shows an error on insert. Read the error message. Common issues: duplicate username or email, or a required field left empty. Fix and try again.
Frequently Asked Questions
Can I use this method to reset an existing admin password?
Yes. Instead of inserting a new user, you can update the user_pass field of an existing admin user with a new MD5 hash. Use the SQL tab: UPDATE wp_users SET user_pass = MD5('newpassword') WHERE user_login = 'admin';
What if my WordPress prefix is not ‘wp_’?
Check the wp-config.php file for the $table_prefix variable. Use that prefix in all table names and meta keys.
Is MD5 hashing secure enough?
MD5 is not secure for password storage, but WordPress will rehash the password using its own algorithm (bcrypt) the first time the user logs in. So it’s acceptable for a temporary fix, but change the password after logging in.
Do I need to create both the users and usermeta rows?
Yes. The users table stores the login credentials, and the usermeta table stores the role. Without the role, the user cannot access the admin area.
Can I do this without phpMyAdmin?
Yes, you can use a MySQL command-line client or a plugin if you have any dashboard access. But phpMyAdmin is the most common method for hosts that provide it.
Will this method work on WordPress multisite?
It’s more complex. For multisite, you also need to set the wp_blog_id and add the user to the site’s user table. It’s safer to use the network admin or a plugin.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.