Add an Admin User to the WordPress Database via MySQL/PHPMyAdmin

Add an Admin User to the WordPress Database via MySQL/PHPMyAdmin

Posted: 9 years ago in  MySQL | Wordpress | Unix | Windows | Mac OS |


In some cases where you lost control of admin user in Wordpress Site or account is deleted, you are locked out of the site. The solution is creating another admin account to remove the old one and do backup your site outside of website using MySQL command-line interface or PHPMyAdmin


In some cases where you lost control of admin user in Wordpress Site or account is deleted, you are locked out of the site. The solution is creating another admin account to remove the old one and do backup your site outside of website using MySQL command-line interface or PHPMyAdmin

I will show you a step by step guide on how to create an admin user in WordPress Database via MySQL. It is same SQL command to put in PHPMyAdmin

Create record in wp_users table

insert into wp_users(user_login,user_pass,user_nicename,user_email,user_url,user_registered,user_activation_key,user_status,display_name)
values("newaccount",MD5("newpassword"),"Luan Tran","admin@minhluan.net","http://minhluan.net","2015-01-01 00:00:00","","0","Luan Tran");

Get the ID of created user

select * from wp_users order by id desc limit 0,1;

Insert meta data for this user, let say ID is 4

insert into 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 wp_usermeta (umeta_id, user_id, meta_key, meta_value) values (NULL, '4', 'wp_user_level', '10');