Reputation: 1065
Hi I have a serious problem. I was working on wordpress and organizing with user account. And mistakenly I deleted my admin account. Then, I could not log in the dashboard. I have the backup but I don't know what to do. If someone knows how to solve this problem, please let me know. Thank you so much in advance!
Upvotes: 0
Views: 7181
Reputation: 3232
As described in this blog post, you can add a admin user directly by SQL input.
If you have PhpMyAdmin, it will be as easy as login into it, navigate to wp_users
table (replace wp_
by your own prefi if you changed it during install) and execute this SQL :
INSERT INTO `your_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', 'your_username', MD5('your_password'), 'Your Name', 'your@email', 'Your Website', '2011-06-07 00:00:00', '', '0', 'Your Display 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');
Remember to replace the values by your own (password, name, email, etc).
EDIT : markratledge's answer may be easier if you have a database backup ;)
Upvotes: 1
Reputation: 17561
I have the backup
A database backup?
If so, restore it with phpmyadmin or adminer in your hosts Cpanel. See http://codex.wordpress.org/Restoring_Your_Database_From_Backup
There are ways to add an admin account via those database tools - see http://www.velvetblues.com/web-development-blog/how-to-add-an-admin-user-to-a-wordpress-database/ - but it's much easier to restore the database backup.
Upvotes: 2