How do I get WordPress admin access via database?

The case should occur only very rarely, but it is not completely absurd: You can no longer get into the backend of WordPress.

Solution: If you still have access to the database, ideally via phpMyAdmin, a new admin access can be set up quickly. Just use the following SQL commands. Before you do this, you have to change the word ‚databasename‘ to the actual database name.

INSERT INTO `databasename`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('4', 'demo', MD5('demo'), 'Your Name', 'test@yourdomain.de', 'http://www.test.de/', '2011-06-07 00:00:00', '', '0', 'Your Name');
 
INSERT INTO `databasename`.`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 `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_user_level', '10');

Then you can log in with the username and password ‚demo‘. These access data should of course be changed as soon as possible!

Without cookies
This website does not use cookies or tracking. More information can be found in the privacy policy.