If you want to add a new user to WordPress database using MySQL using phpMyAdmin or a similar tool, you can use the following snippet:

INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES
('admin', '$P$Bg/Ol6U.M07OGU7sKEZvIyl.mxuQQw.', 'admin', '[email protected]', '', '2018-12-21 16:34:15', '', 0, 'admin');

This will add admin user with password 1234. You can change username and email to anything you like. You can login using this password and update it on user profile settings of WordPress admin panel. To add new user administrator capabilities you need to edit and run following code:

INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '3', 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}');

In this code you need to fix user_id field (‘3’ in this code) for the user on the database. You can see a list of users on the wp_users table on your WordPress database. If your WordPress installation doesn’t use default table prefix wp_, then you need to update wp_capabilities using your own table prefix also (eg. wp78_capabilities)

Comments (0)

Leave a Reply

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