How to ad new admin user via phpMyAdmin

Hello,

unfortunately the “Forgot Password” function seems not to work (Revo 2.8.3), now I need to reset password for me (my admin user) via phpMyAdmin. I created a new user, I entered an user name, a md5 hash as password, and I changed hash_class to hashing.modmd5. But can’t login with new user and clear password.

Also tried a version with PBKDF2 hash and salt an changed hash_class back to hashing.modPBKDF2. Any hints here?

Or how to possibly repair the “Forgot Password” function (maybe I need to change to smtp?)

Thanks

Why did you create a new user and not just change the password and hash_class fields of the existing user?

I assume a new user must also be added to the right user group to make it work. And maybe needs a corresponding row in the user profile table (modx_user_attributes) as well.

Mate just run this in you phpmyadmin and replace “theusername” for the user you need to recover the passwors and “the-new-password” for any password you want :+1::

UPDATE modx_users SET hash_class = 'hashing.modMD5', password = MD5('the-new-password') WHERE username = 'theusername';

Then, clear the “core/cache” folder and thy to login.

Yes, was aware of this. Didn’t want to mess with the original admin user … Thx

You could install another MODX site of the same version with the admin user having the same username and email. Then copy that admin record to the troubled site’s modx_users table, replacing the admin user’s record.

Nothing would change but the admin users password, which you’d now know if you made a note of it.

Thanks, that’s a good idea. I know, in a perfect world you should never need this. I my 17 year MODX history, this is the 3rd time I need that, as an old customer is coming back after some years …

sorry to bump this but spent an hour going around in circles and really stuck - recently moved hosting and just realised the Forgotten Password isn’t working (Revo 3.0.1-pl)

tried the UPDATE modx_users SET hash_class = 'hashing.modMD5', password = MD5('the-new-password') WHERE username = 'theusername';

and went to clear “core/cache” folder as suggested above - i did this by deleting everything in the core/cache folder and boom site down ‘Site Unavailable’ , fortunately i had backed up the core/cache, so putting it back the site is fine - but can’t log in.

The tried the API method on this page - Resetting a User Password Manually - Troubleshooting Security | MODX Documentation - but it said “ERROR: No user with username administrator” when there clearly is, i can see it in phpMyAdmin.

Any help please - I see Bob’s post but unsure how to copy a record between databases.

thanks, David

Everything in the core/cache folder should get recreated when the cache file doesn’t exist.
So there seems to be a bigger problem than just a forgotten password.

Make sure the database settings are correct in core/config/config.inc.php and maybe take a look at the MODX error log (core/cache/logs/error.log) to see if something gets logged.

For how to copy the info from one DB to another, open PhpMyAdmin in two different browsers or browser windows. Click on “Edit” next to the admin’s record in each, then cut and paste any data that 's not the same from the good site to the bad one. Don’t get it backwards.

i’ve double checked the config settings and the DB permissions for the user all seem fine - checking the error.log - literally thousands of the same error;

[2024-01-22 21:49:24] (ERROR in xPDO\xPDOConnection::connect @ /mypath/html/core/vendor/xpdo/xpdo/src/xPDO/xPDOConnection.php : 89) SQLSTATE[42000] [1044] Access denied for user 'myDBuser'@'localhost' to database 'myDatabase'

[2024-01-22 21:49:24] (ERROR @ /mypath//html/core/vendor/xpdo/xpdo/src/xPDO/Om/xPDOQuery.php : 670) Could not construct or prepare query because it is invalid or could not connect: SELECT `modSystemSetting`.`key` AS `modSystemSetting_key`, `modSystemSetting`.`value` AS `modSystemSetting_value`, `modSystemSetting`.`xtype` AS `modSystemSetting_xtype`, `modSystemSetting`.`namespace` AS `modSystemSetting_namespace`, `modSystemSetting`.`area` AS `modSystemSetting_area`, `modSystemSetting`.`editedon` AS `modSystemSetting_editedon` FROM `modx_system_settings` AS `modSystemSetting`

This looks to me like the database credentials are wrong.
MODX doesn’t seem to be able to connect to the database at all.

Thanks for all your help. Something wrong with credentials and / or permissions.

My solution was export the SQL database, create a new database, with a brand new user, then import the db.sql file. Then changed everything in the config file. And boom the new password created in above with the UPDATE modx_users query worked.

Phew !