These commands let you quickly add a new administrator user account in WordPress using MySQL. Just replace the variables at the beginning with the values you want to use and run it.

-- Set user variables
SET @USERNAME = '<USERNAME>';
SET @PASSWORD = '<PASSWORD>';
SET @DISPLAY_NAME = '<NAME>';
SET @EMAIL = '<EMAIL>';
SET @URL = '<URL>';

-- Add new user
INSERT INTO `wp_users`
	(`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `display_name`)
VALUES
	(@USERNAME, MD5(@PASSWORD), @DISPLAY_NAME, @EMAIL, @URL, NOW(), @DISPLAY_NAME);

-- Get new user ID
SELECT @NEW_ID:=ID FROM `wp_users` WHERE `user_email` = @EMAIL;

-- Add Capabilities and User Level
INSERT INTO `wp_usermeta`
	(`user_id`, `meta_key`, `meta_value`)
VALUES
	(@NEW_ID, 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}'),
	(@NEW_ID, 'wp_user_level', '10');

NOTE: You will need to replace the “wp_” in the table names with your prefix if yours is different.

0 0 votes
Article Rating
in MySQL, WordPress
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments