Have you ever found yourself with a WordPress site you don’t have a login for, armed only with database access? No? We have.

Or worst case, your site has been hacked and the admin user has been deleted.

There is a super simple solution that we use a lot here at Lime Web Development. You’ll want to open up your favourite database tool -SQLyog, phpMyAdmin or Adminer for example, select the WordPress database and run this SQL.

You should always make a backup of your database first.

INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('lwd', MD5('lwd'), 'LWD', 'hello@lwd.rocks', '0');
 
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
VALUES (NULL, (SELECT MAX(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
 
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
VALUES (NULL, (SELECT MAX(id) FROM wp_users), 'wp_user_level', '10');

 

Replace the user_login, user_email and user_pass with values of your choice and run these 3 queries in the database tool of your choice. Instant access! (And no, that isn’t our default password).

 

Share on Google+

Lime Web Development is a small and focused specialist web development agency based in Chorley, Lancashire. We primarily produce PHP web applications in WordPress, WooCommerce and CakePHP.

Create a WordPress User Directly in the Database

Leave a Reply

Your email address will not be published. Required fields are marked *