Add WordPress Admin Account to Database wp_users Table

Here is a guide on how you can add in a newWordPress admin account username and password to the database. What you do need to do this have access to the WordPress database by having the database name and password.

Also instead of adding an extra admin account you can just change the admin password itself (see last).

The MySQL Code

INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('admin', MD5('password'), 'firstname lastname', '[email protected]', '0');

INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');

INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');

This is the needed MySQL code to add the admin user account, change the marked areas to your needs.

Adding the WordPress Admin Account via phpMyadmin

In phpMyAdmin you can add the MySQL code in the MySQL tab whilst having the right database loaded – but as a precaution take a back up before running the code. Paste in the code from above with your changes and click on the go button.

wordpress-add-admin-account

Once the code is executed, you will then be able to login via the WP Admin page with the new account details.

Changing the WordPress Admin Account Password

Instead of adding a new WP admin account you can also change the existing admin password in the wp_users table – go to the wp_users table and click edit on the admin account – look for the password field, change the user_pass function to MD5 and change the password value and click Go.

change-admin-password-database

Leave a Comment