skip to Main Content

I’ve used wp all in one plugin to migrate my site to aws lightsail. However, it also migrated the old credentials which was owned by the previous webhosting company. I’m not able to obtain those credentials. In this case, how can I reset my user and password to my new WordPress? My lightsail ssh has a bitanami interface on the console, I suppose that is how I should go about it but I’m exactly sure about the steps.

3

Answers


  1. if you have ssh access you can change the password by following MySQL query

    UPDATE wp_users SET user_pass = MD5('your-new-password') WHERE ID = 'any-admin-ID'

    Or if you don’t know any administrator account you can create one By

    INSERT INTO wp_users (ID, user_login, user_pass, user_nicename, user_email, user_url, user_registered, user_activation_key, user_status, display_name) VALUES ('4', 'new-username', MD5('your-new-password'), 'Your Name', '[email protected]', 'http://www.test.com/', '2021-06-17 00:00:00', '', '0', 'Your Name');

    and assign it as administrator by following queries

    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');

    *Replace wp_ with your DB prefix

    Login or Signup to reply.
  2. You should use wp cli for resetting password.

    • First install wp cli
    • Run wp user list --role=administrator to get administrator user id
    • Run wp user update 1 --user_pass=newpass to reset password.
    Login or Signup to reply.
  3. I tried these codes in Lightsail, but it didn’t work, so I found a way.

    mysql -u root -p bitnami_wordpress -e "..."
    
    mysql -u root -p bitnami_wordpress -e 
    "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";}'
    );"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search