[How to] Add User to WordPress using SQL INSERT
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', 'a[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
)
Deal Notice: We are using A2 hosting for all of our websites, and we are really happy with their service. So we wanted to share you this discount link for you to try it out. If you get a hosting using this link, you will also help us build better content for you: SSD Hosting - 300% Faster Than Standard Hard Drives