How to Add a WordPress Admin User in phpMyAdmin
By Sakthivel | August 1, 2024
Introduction:
Numerous websites around the world use WordPress, a powerful content management platform. Although users are usually created within WordPress’ user interface, there are situations where creating a WordPress Admin User directly in the WordPress database via phpMyAdmin is necessary. This may be required for troubleshooting, regaining access to a WordPress site, or performing various administrative duties.
Step 1: Access phpMyAdmin:
- Access your web hosting control panel by logging in.
- Locate the phpMyAdmin icon within the control panel interface.
- Click on the icon to launch phpMyAdmin.
Step 2: Select your WordPress database:
In phpMyAdmin, databases are listed on the left sidebar. Find and select the database associated with your WordPress setup, typically starting with your username or account name.
Step 3: Locate the WordPress user’s table:
After choosing the appropriate database, locate a table called wp_users. The prefix wp_ could differ based on how your WordPress setup is configured. This table is where user data is stored.
Step 4: Insert a new user:
- Access the wp_users table by clicking on it.
- Navigate to the “Insert” tab or button, typically found on the top navigation bar.
Step 5: Add user details:
Please complete the necessary fields to establish a new user account. The following information is required:
- ID: Please keep this field empty as it will automatically increment.
- user_login: Input the desired username for the new user.
- user_pass: Create a secure password for the user. Remember that passwords are encrypted in the database, so you will need to utilize a hashing function to generate the password. You can generate a hashed password using an online tool or PHP code.
- user_nicename: Typically, this is the same as the username.
- user_email: Provide the email address linked to the user.
- user_registered: Specify the registration date and time for the user in the format YYYY-MM-DD HH:MM:SS.
- user_status: Set this to 0 for active users.
- display_name: Input the display name for the user.
After completing all required fields, simply select the “Go” or “Save” option located at the bottom to add the new user to the database.
Step 7: Grant user capabilities:
To grant administrative privileges to a user, you will need to make an entry in the wp_usermeta table. Locate the wp_usermeta table and add a new row with the following information:
user_id: Assign this to the ID of the user you have created in the wp_users table. (Refer to the wp_user row digit when creating the user.)
meta_key: Set this to wp_capabilities. (Use your database prefix accordingly.)
meta_value: Set this to “a:1:{s:13:”administrator”;b:1;}” to provide administrative privileges. If necessary, replace “administrator” with the appropriate role.
You can also use the below values for giving the roles:
a:1:{s:10:”subscriber”;b:1;} – Subscriber
a:1:{s:11:”contributor”;b:1;} – Contributor
a:1:{s:6:”author”;b:1;} – Author
a:1:{s:6:”editor”;b:1;} – Editor
a:1:{s:13:”administrator”;b:1;} – Administrator
Assign Role:
Assign Role ID:
Important Notes:
- Ensure strong passwords are used and securely kept.
- Exercise caution when directly modifying the database, as incorrect changes may break your WordPress site.
- Moreover, remember to back up your database before implementing any changes to ensure you can revert to a previous state if needed.
- In case you are unable to access your WordPress site, a typical solution is to generate a fresh WordPress Admin User through phpMyAdmin.
Conclusion:
By using the instructions provided in this guide, you’ll be able to easily manage WordPress users through phpMyAdmin.