Ever found yourself locked out of your WordPress admin account? Or maybe you need to create a new admin user for your site, but you can’t do it the traditional way. Whatever the reason, knowing how to add an admin user directly through the WordPress database can be a lifesaver.
Let’s 🚀
Getting Started
Generate a Hashed Password
First things first, you need a hashed password for the new user. WordPress uses a specific hashing system, so you can’t just enter a plain text password. Use online tools like WordPress Password Hash Generator or WPRefers to generate one.
Accessing the Database
Assuming you have access to your website’s database (usually through phpMyAdmin or a similar database management tool), here’s what you need to do:
Insert User Data
Navigate to your WordPress database, often named wp
or something similar. Then, run the following SQL query to create a new user. Replace the values with your desired username, email, and the hashed password you generated.
I’m using $P$BY1w0mqOCkzKHikYeyaoCKZuZqckhL0
which is the encrypted value for password
ad running the query on a MySQL database.
Set Admin Privileges
Next, you need to give this user admin privileges. This is done by inserting data into the wp_usermeta
table.
And there you have it! You’ve successfully added a new admin user to your WordPress site directly through the database. This method is particularly useful in emergency situations, like when you’re locked out of your admin account.
Remember, with great power comes great responsibility. Only use this method when necessary and always ensure your WordPress site’s security is up to date.
Looking for more tips and tricks? Check out my previous posts on Dealing With Hung Terminal Sessions and Debugging Timeout Issues in Web Applications. Stay savvy! 🚀