How to manually add a WordPress Admin
Well, we ran into an interesting problem the other day where we were able to install WordPress on a Windows 8 laptop for local development, but it only partially installed and stopped at step 2.
We hit refresh on the page, which resubmitted the login details from the first step and it takes you to a screen that says WordPress has already installed.
Now there are a couple reasons this error can come up…most likely because of a PHP server side timeout error…unfortunately the second step it failed on is the step where it adds the admin user to the WordPress install, so if you click the “Log in” button it takes you to the wp-login.php page, but you don’t have a user to login with, and if you go to the database and look in the users table you can see that it’s empty….so your options are to keep futzing with the php.ini file and restarting Apache until it installs correctly (and for that you just delete all the tables in your WordPress database and hit the /wp-admin/install.php file again), or we can install the admin user manually in the database. No manually adding a user to a WordPress install involved modifying the users, usermeta, and options table (in your install they will probably be called the wp_users, wp_usermeta, and wp_options tables or whatever your prefix might be that you’ve set in your configuration file). So in your MySQL database (or MariaDB I suppose) you want to run the following SQL queries to add rows to the relevant tables. Change “prefix” to whatever value you specified in step 1 for the wordpress database prefix. You can also find it in your wp-config.php file under $table_prefix = ‘prefix_’;
INSERT INTO `prefix_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('newadmin', MD5('pass123'), 'firstname lastname', '[email protected]', '0');
INSERT INTO `prefix_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM prefix_users), 'prefix_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `prefix_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM prefix_users), 'prefix_user_level', '10');
Make sure you specify your prefix in prefix_capabilities in the prefix_usermeta table, and prefix_user_level in the prefix_usermeta table (and notice the prefix_capabilities, and prefix_user_level above as well). On a side note, if you have multiple wordpress installs in different directories on the same website make sure prefix_user_roles in prefix_options has the right prefix. Let us know if you have any problems with these directions and we’ll see if we can’t point you in the right direction.