Adding a WordPress Admin User via SQL

by Jun 5, 2025IT Tips0 comments

Using MySQL CLI or MySQL Workbench

USE yourwpdb;
# remember to take into account the custom table prefix if you have one 
# e.g. 7jhdy66N_ is a custom table prefix and replaces the default wp_ prefix
INSERT INTO `7jhdy66N_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`) 
VALUES ('[email protected]', MD5('MySuperSecretPW'), 'Rodney Russey', '[email protected]', '0');

INSERT INTO `7jhdy66N_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
VALUES (NULL, (Select max(id) FROM  `7jhdy66N_users`), '7jhdy66N_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');

# not sure if this is needed
INSERT INTO `7jhdy66N_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
VALUES (NULL, (Select max(id) FROM  `7jhdy66N_users`), '7jhdy66N_user_level', '10');

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.