# Creating a WordPress admin user in MySQL using phpMyAdmin

> Create a new WordPress administrator account directly in the database with phpMyAdmin when you are locked out.

Source: https://helpcenter.ruachost.com/wordpress/guides/creating-wordpress-admin-user-in-mysql-using-phpmyadmin/

If you’ve lost access to your WordPress administrator account, you can create a new admin user directly in the database using **phpMyAdmin**. On **ruachost.com**, this method bypasses the WordPress dashboard and gives you immediate access.

## Why Use phpMyAdmin?

- Recover access if your admin login is lost or corrupted.
- Create emergency admin accounts without reinstalling WordPress.
- Manage users directly at the database level.

## Steps to Create an Admin User in phpMyAdmin

1. **Log in to cPanel** (or your hosting control panel).
2. Go to the **Databases** section → Click **phpMyAdmin**.
3. Select your WordPress site’s database from the left sidebar.

   - Look for the table named `wp_users` (prefix may vary, e.g., `wpem_users`).
4. Click the **Insert** tab.
5. Fill in the form:

   - **user_login** → Desired username (e.g., `newadmin`).
   - **user_pass** → Enter a password and select **MD5** in the Function dropdown.
   - **user_email** → Your email address.
   - **user_registered** → Current date/time.
   - **user_status** → Set to `0`.
6. Click **Go** → The new user will be added.

## ⚙️ Assigning Admin Privileges

1. In the same database, open the table `wp_usermeta` (or `[prefix]_usermeta`).
2. Click the **Insert** tab.
3. Fill in the form:

   - **user_id** → The ID of the user you just created (from `wp_users`).
   - **meta_key** → `wp_capabilities` (or `[prefix]_capabilities`).
   - **meta_value** →

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

     *(For some prefixes, use* `a:1:{s:13:"administrator";b:1;}`*)*
4. Click **Go** → This grants administrator rights.

## Important Notes

- Always back up your database before making changes.
- Ensure you use the correct table prefix (it may differ for security reasons).
- After creating the user, log in via the WordPress admin login page with the new credentials.
