• Hi Everyone, first post, hope someone can help.
    A site I developed for a friend – have been locked out for last couple of months and went to tackle today via edit of database.
    Used query below and all seemed to work ok (lines confimed as added in SQL) and checked in database – could see all relevant lines and values added correctly in right places.
    Query used as below: (Note: xxx covers actual value I added)

    INSERT INTO wp_users (ID, user_login, user_pass, user_nicename, user_email, user_status, display_name)
    VALUES (‘100’ , ‘demo5’, MD5(‘xxx’), ‘demo5’, ‘xxx@hotmail.com’, ‘0’, ‘demo5’);
    INSERT INTO wp_usermeta (umeta_id, user_id, meta_key, meta_value)
    VALUES
    (NULL, ‘100’, ‘wp_capabilities’,
    ‘a:1:{s:13:”administrator”;b:1;}’); INSERT INTO wp_usermeta (umeta_id, user_id, meta_key, meta_value) VALUES (NULL, ‘100’, ‘wp_user_level’, ’10’);

    I have tried different versions of the line: a:1:{s:13:”administrator”;b:1; as I believe it was different in earlier versions. I have also checked the lines inserted via this query against another database from a similar version of WPress I have that is working and it corresponds exactly.
    Php version: Version information: 3.5.8.2
    Any user created as admin (no matter what I call that user and with user_level 10) is greated with a shake of the head when I try to log into the WP admin interface. Additionally, when I try to retreive p/word via web interface and add either the correctly added user or that users associate email address, it says user and / or email address dont exist.
    Any help would be greatly appreciated.!!!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Rather than creating a whole new administrator user, much easier to just replace the password of the existing administrator. Then you can login and run wordpress as normal, including possibly adding new administrators.

    First backup your database.
    Read the name of your administrator (it should not be “admin” but it may be).
    Edit your wp_users table, and replace the password with MD5(“newPassword”)

    Now login.

    Thread Starter jaybay13

    (@jaybay13)

    Hi Ross, Thanks for the feedback – tried that a few times before I went to the next step of adding whole new user direct into SQL – same result, not able to log in with new password. Its as though either the site has been hacked(but I cant see any evidence on the surface- site still functions as usual and was secure with relatively new updates, good passwwords), or some strange issue elsewhere in the database that pertains just to user login in or creation???

    Have you tried a password reset? Do you get the email?

    Thread Starter jaybay13

    (@jaybay13)

    Hi Evan, when I try to retreive p/word via web interface and add either the correctly added user or that users associate email address, it says user and / or email address dont exist, yet they are clearly there as correct rows/ entries in the database.

    That is not right. If you can see that the user exists in the database but it’s still giving you that error I would make sure your site is correctly linked to the proper database.

    Check your wp-config.php file for the database credentials and make sure they are correct. Something doesn’t seem right.

    Thread Starter jaybay13

    (@jaybay13)

    I know its not right- I am pulling my hair out! :-0. DB name, user and password are all ok in wp-config.php file and match in SQL. As I said, site is working fine from an end user/brwosing perspective

    Thread Starter jaybay13

    (@jaybay13)

    So I copied all WPress files across to a new folder under a new domain name, created and named a new database, user & DB p/word. Edited the wp_config.php file to point to new DB, exported old database and imported into newly created DB, ran search & replace on DB to change www. from old domain to correct new domain name opened browser and website cam up ok on new domain. Hey presto- could log in as the user that I created in database. Went into dash and updated all plugins, themes and Wpress to 3.9.1. Reversed process and loaded changed (=now updated)files onto old domain folder, exported database and imported to new database- ran search & replace on DB to change www. from new domain back to correct old domain name, updated wp_config, opened browser and website came up ok on old domain, BUT again went to log in to console with new user created that I can see clearly in the correctly pointed database and get SAME sort of error: ERROR: Invalid username. Tried to recovery with username and email address associated with that user, get error: Invalid username or e-mail. This is wierd, only difference is domain name- can access WP admin console with users on 1 domain and not on the other. Any ideas – I am all out. Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Locked out of WP site, cant add new admin user via SQL’ is closed to new replies.