New WordPress admin user over SQL phpMyAdmin

How to make user over FTP is here.

You will need:

  • access to wp-config.php because there is database host, username and password
  • access to phpMyAdmin (if it is ‘localhost’, you have to investigate the address)

You don’t need:

  • access to WordPress dashboard for creating new admin user :)

After login to phpMyAdmin click on tab SQL and paste following snippet. It will create new admin user with login name newadmin and password newadmin

INSERT INTO `w_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('newadmin', MD5('newadmin'), 'newadmin', 'any@email.com', '0');
INSERT INTO `w_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
VALUES (NULL, (Select max(id) FROM w_users), 'w_capabilities', 'a:1:{s:13:"administrator";b:1;}');
INSERT INTO `w_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
VALUES (NULL, (Select max(id) FROM w_users), 'w_user_level', '10');

Note the w_ It is a table prefix, change it into what you are using.

After getting access over site, you can do anything.

Security recommendations:

  • keep you ftp access safe with long password, or disable ftp access if you don’t need it
  • keep file attributes strict for file wp-config.php, use 640 or 644