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.
-
So your site is already up and running correctly, but you don't know the username or email of the old admin account, and you just wanted to be able to login to the site? – Sally CJ Jun 14 '21 at 16:40
3 Answers
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', 'test@yourdomain.com', '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

- 63
- 7
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";}'
);"

- 4,438
- 4
- 14
- 41

- 1