Created
January 29, 2026 09:36
-
-
Save esedic/16628febf87ac91181e81276ea9e7a7e to your computer and use it in GitHub Desktop.
Create WP admin user with SQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- WordPress Admin User Creation Script | |
| -- Instructions: | |
| -- 1. Open phpMyAdmin and select your WordPress database | |
| -- 2. Go to the SQL tab | |
| -- 3. Copy and paste this entire script | |
| -- 4. Modify the values in the SET statements below as needed | |
| -- 5. Click "Go" to execute | |
| -- ==================================== | |
| -- CONFIGURATION - Modify these values | |
| -- ==================================== | |
| SET @new_username = 'newadmin'; | |
| SET @new_password = 'SecurePassword123!'; -- Change this to a strong password | |
| SET @new_email = '[email protected]'; | |
| SET @new_display_name = 'New Admin'; | |
| SET @new_first_name = 'New'; | |
| SET @new_last_name = 'Admin'; | |
| -- ==================================== | |
| -- DO NOT MODIFY BELOW THIS LINE | |
| -- ==================================== | |
| -- Insert the new user | |
| INSERT INTO wp_users (user_login, user_pass, user_nicename, user_email, user_registered, user_status, display_name) | |
| VALUES ( | |
| @new_username, | |
| MD5(@new_password), -- WordPress will convert this to proper hash on first login | |
| @new_username, | |
| @new_email, | |
| NOW(), | |
| 0, | |
| @new_display_name | |
| ); | |
| -- Get the user ID that was just created | |
| SET @new_user_id = LAST_INSERT_ID(); | |
| -- Set user meta data | |
| INSERT INTO wp_usermeta (user_id, meta_key, meta_value) VALUES | |
| (@new_user_id, 'nickname', @new_username), | |
| (@new_user_id, 'first_name', @new_first_name), | |
| (@new_user_id, 'last_name', @new_last_name), | |
| (@new_user_id, 'description', ''), | |
| (@new_user_id, 'rich_editing', 'true'), | |
| (@new_user_id, 'syntax_highlighting', 'true'), | |
| (@new_user_id, 'comment_shortcuts', 'false'), | |
| (@new_user_id, 'admin_color', 'fresh'), | |
| (@new_user_id, 'use_ssl', '0'), | |
| (@new_user_id, 'show_admin_bar_front', 'true'), | |
| (@new_user_id, 'locale', ''), | |
| (@new_user_id, 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}'), | |
| (@new_user_id, 'wp_user_level', '10'); | |
| -- Display success message | |
| SELECT CONCAT('Success! Admin user "', @new_username, '" created with ID: ', @new_user_id) AS Result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment