October 02, 2014
Ever been hacked or had a change of staff and completely lose access to the website you’ve put so much time and effort into? The following code goes a long way, if you drop this into your sql through phpMyAdmin, this will create an Administrator account, granting you access to your website once again. Simply update the fields to the name of your database, and the username you would like to use to access the site. Voila!
INSERT INTO `Your_DB_Name`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('4', 'katherine', MD5('demo'), 'Katherine Goodmanson', '[email protected]', 'http://www.wpbeginner.com/', '2011-06-07 00:00:00', '', '0', 'Katherine Goodmanson'); INSERT INTO `Your_DB_Name`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `Your_DB_Name`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_user_level', '10');