How To Create A WordPress Admin Login Using MySQL

You can do this simply by running the following SQL commands through phpMyadmin or through command line MySQL.

1. First insert the new user account into the database.

If you’re using command line MySQL then you will need to select the database first using the “use” command below:

use wp_mywordpressdatabasename

Now that you’ve selected the database, you can run the following query to insert the new user account into the wp_users table of your WordPress Database. You will want to fill in your details below before executing the query. You enter this query under the “SQL” tab within phpMyAdmin.

INSERT INTO `wp_users` (`id`,`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('','john', MD5('newpassword123'), 'John Smith', '[email protected]', 'http://geektank.net/', '2013-29-03 00:00:00', '', '0', 'John Smith');

 

If successfully you should see:

Query OK, 1 row affected (0.00 sec)

Note, the field ‘ID’ is blank because this field is set to auto-increment within the table, a number will automatically to the ‘ID’ field for the new user.

2. Find out what ID your new account received.

Now that you have the successfully inserted the new record into the wp_users table. You want to know the new ID for the new account. You can find this rather easily with phpMyAdmin, but if you’re using the mysql command line simply run the following.

select * from wp_users where user_login = "john";

Which should return:

+----+------------+----------------------------------+---------------+--------------------------+-------------------------+---------------------+---------------------+-------------+--------------+
| ID | user_login | user_pass | user_nicename | user_email | user_url | user_registered | user_activation_key | user_status | display_name |
+----+------------+----------------------------------+---------------+--------------------------+-------------------------+--------+------------+---------------------+-------------+--------------+
| 5 | john | 8359b10e30dfabd587a5661e52249101 | John Smith | [email protected] | http://geektank.net | 2012-08-23 00:00:00 | | 0 | John Smith |
+----+------------+----------------------------------+---------------+--------------------------+----------+--------------+---------------------+---------------------+-------------+--------------+

The ID for the new account we created is 5.

3. Making the new WordPress Account an Administrator (wp_usermeta bits)

Even though we added a new user, it doesn’t have Administrator rights yet. We need to add a couple of entries to the wp_usermeta table. Taking the ID of the new user we create the following two queries.

INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '5', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '5', 'wp_user_level', '10');

These queries will tell provide Administrator rights to our new user account.

4. Enjoy the new account!

You’re done!

 


Did you like this article?


0 Shares:
You May Also Like

Guide to upgrading Drupal using SSH Commands

A well written guide on how to upgrade Drupal using SSH commands
This guide is meant to augment the official Upgrade guide. Please read the official upgrade steps in UPGRADE.txt as well as in the Drupal.org Dcoumentation thoroughly to ensure that you understand every aspect of the upgrade process. This guide is for more advanced users with SSH experience.
Read More

Microsoft changes mind, agrees to fix IE’s URI handler

Microsoft agrees to release a patch to fix some of the security issues but not all in Internet Explorers URI Handler. I don't understand why Microsoft has such a lazy stance on security, I want to use Internet Explorer just as securely as any other browser. One mis-typed url after a fresh install of Windows could cause malicious software to gain entry to me desktop.
Read More