Lost access to Wordpress
-
-
On my Cloudron-powered WordPress website I have made a solution. Simply open your Cloudron UI and access the Terminal.
dbname=`head -20 wp-config.php | grep 'NAME' | cut -d\' -f4` dbuser=`head -20 wp-config.php | grep 'USER' | cut -d\' -f4` dbpass=`head -20 wp-config.php | grep 'PASS' | cut -d\' -f4` dbhost=`head -20 wp-config.php|grep 'HOST'|cut -d\' -f4|cut -d: -f1` mysql -h $dbhost -u $dbuser -p$dbpass -D $dbname -e "insert into wp_users (user_login, user_pass, user_nicename, user_email, user_url, user_registered, user_activation_key, user_status, display_name) values ('emergency','','emergency','emergency@localhost','','2023-01-10 01:23','',0,'Emergency');set @emerid = (SELECT ID FROM wp_users WHERE user_email = 'emergency@localhost');insert into wp_usermeta (user_id, meta_key, meta_value) values (@emerid, 'wp_capabilities', 'a:1:{s:13:\"administrator\";b:1;} ');UPDATE wp_users SET user_pass=\"582f40dea63ec71c7f12d8adbe3230b4\" WHERE ID = @emerid;"
This should inject a user:
emergencyWith password:
techspanHelpsy0u#Obviously change the username/password to your own liking prior to pasting in the commands. The password is in MD5 hash format, so just use an "md5 generator" and then where you see 582f40dea63ec71c7f12d8adbe3230b4...... put your own password MD5 hash, hint: Google MD5 hash generator and then type your_wanted_password, generate the hash, and replace!
If you have any issues, or find this works - either way please let me know so I can help improve this copy paste solution
Side-note one could set a variable of a preferred password by the user, then use md5sum to generate said md5 hash to pass through to the SQL.
However, all that said - the wp cli solution does all this for you.
wp user create wild wild@localhost.0000000 --role=administrator
This would generate a user
wild
with a randomly generated password which would display on the terminal output.