Sometimes, especially when dealing with WordPress Multisite networks or during catastrophic lockouts, you might not be able to create a user through the standard WordPress dashboard. In these cases, you can use SQL queries within phpMyAdmin to manually insert a user and grant them administrator or Super Admin privileges.
In this tutorial, I will guide you through the two-step process of creating a standard admin and then promoting them to a Super Admin for Multisite environments.
Step 1: Creating a Standard Administrator User
First, we need to insert the user record into the wp_users table. Replace ‘myPassword’ with a secure password; the MD5() function will handle the initial hashing (though WordPress will re-hash it securely on first login).
INSERT INTO wp_users (user_login, user_pass, user_nicename, user_email, user_url, user_registered, display_name)
VALUES ('newadmin', MD5('securePassword123'), 'New Admin', 'admin@example.com', 'https://example.com', NOW(), 'New Administrator');
Next, we must assign the administrator role to this user in the wp_usermeta table. Important: You must know the user_id of the user you just created. If it’s a fresh install, it might be 2, but check your wp_users table first.
INSERT INTO wp_usermeta (user_id, meta_key, meta_value)
VALUES (2, 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}');
INSERT INTO wp_usermeta (user_id, meta_key, meta_value)
VALUES (2, 'wp_user_level', '10');

Step 2: Promoting to Super Admin (Multisite Only)
In a Multisite network, being an administrator of the main site isn’t enough to manage the entire network. Super Admin status is stored in the wp_sitemeta table under the site_admins key.
Warning: The site_admins value is a serialized array containing the usernames of all Super Admins. Overwriting it with a simple UPDATE will remove all other Super Admins. It is safer to edit the field manually in phpMyAdmin to add your username to the array.
The serialized format looks like this for a single user named ‘rudrastyh’:
a:1:{i:0;s:9:"rudrastyh";}
If you want to add a second user named ‘misha’, the array would be:
a:2:{i:0;s:9:"rudrastyh";i:1;s:5:"misha";}
a:2:indicates an array with 2 elements.i:0;is the index.s:9:is the string length of the username.
By following these steps, you can regain control of your WordPress site even when the dashboard is inaccessible. Always ensure you have a full database backup before running manual SQL queries.
