Reset admin password via SSH?

Is there a way to reset the Mautic admin password via SSH?

The password reset email doe snot seem to send when mailer is set to use sendGrid so I am permanently locked out of Mautic.

You can try to use MySQL client to reset your password.

BUT: You will have to use the proper function (like md5() or sha()) to hash it, otherwise it will not work.

Another BUT: Please don’t empty your password in the database. The Mautic GUI won’t accept an empty value. :slight_smile:

It seems that Mautic uses bcrypt to hash passwords. You will have to bcrypt your new password and write it to the DB.

I’m in - thank you PeterTL

That’s good to hear!

Would you mind providing a little step-by-step? Maybe the issue happens to someone else - they will be happy to have something at their hands.

1 Like

One can use the above string to “reset” the password using database (e.g. via PhpMyAdmin).

Put that on the password field in the desired user in the database:

$2a$04$LrQYZmEMFi7GghF0EIv4FOdNv8bFcnlXM9Bta0eb8BWLLlRwcKrUm

Then the user will be able to login using the password “secret” .

Change it after that using the Mautic interface.

5 Likes

Tried reseting the admin password to “$2a$04$LrQYZmEMFi7GghF0EIv4FOdNv8bFcnlXM9Bta0eb8BWLLlRwcKrUm” and I’m still not able to login.

Is there any way with SSH or Mysql access to reset the Admin Password? Thanks!

Bump still locked out… can anyone help!! Thanks!

if you have ssh access to your server you can do the following:

  1. Type this command: sudo mysql -u root
    This will log you into mysql,
  2. then type: show databases;
    This will show you your databases, usually Mautic default install uses DB name mautic,
  3. Type: use mautic; (you can replace the name of the database if you have a different name)
  4. Type: select id, username from users;
    This will give you a list of users
  5. Type: UPDATE users SET password = “a5b253d8484925a3b4fba260768416dfdcbeaed639bb3435c566cbf54721f846903725c7283cf9ab1f090f179d015f46a50b5e798695547eda6e2342db8918a2” where id = 1; make sure you are using the id of the user you want to update.

now you should be able to login with password 12345678.

Hope that works

2 Likes

Your steps for resetting from phpMyAdmin by changing password and using the password: secret just saved me from a meltdown. Thank You!!

1 Like

This isn’t working for me. Tried resetting password from PHPMyAdmin as well as directly using mysql queries. Tried both passwords suggested here but still can’t login.

Hi and welcome @dinwal

can you take a screenshot of your mysql table of users. I know these are stupid questions, but are you login in with the same user you are changing in the mysql table ?

Another thing to do is maybe go and remove your cache from mautic.
2.x: /var/www/mautic/app/cache. do rm -rf *
3.x:/var/www/mautic/var/cache

Hi guys,
Based on the advice posted by @mikew and others, I have created this blog post with the specific steps required to “reset” you master.admin password.

1 Like

@Yosu_Cadilla this is great, would you be willing to contribute it to the Knowledgebase?

Found a super easy solution if you do not have access to terminal but PHP Admin through Plesk Gui or similar. So if you are in Plesk/Cpanel for example, what you are going to do is click on the PHP Admin of your Database. Once you are in there follow these steps

  1. Search for “users” - You will see a database that should come up with your Mautic Users. Click on the Admin User
  2. You will see a field called password. Delete whatever is there (save it somewhere just in case) and replace it with $2y$13$VkE7UjFetqAM13oT4v/VYOfRCGrJ4hbr0zuwRZo6KVfDnNb16WFwy
  3. Press on the “Go” button on the bottom right, this is like pressing the save/execute button.
  4. You should now be able to login with the username and password as madmin

1 Like

PS I should also state that this worked for me with Mautic Version 4.4.12 through a web install not docker, save your old password before you try!

I implemented a command in custom plugin that enables you to reset password.

Plugin is for M5.

Hello

You can reset any mautic password via the ssh shell using the console commands with just one line.

Show a list of mautic users:

php bin/console doctrine:query:sql "select email from users;"

Reset a mautic user via email and set a random generated password:
(Copy and paste this line into the ssh shell but changing the email address of course)

EMAIL="admin@localhost.local" CLIENTPWD=$(openssl rand -hex 8) MAUTIC_ENCODED_PWD=$(php bin/console security:encode-password --no-interaction --ansi "$CLIENTPWD"|grep 'Encoded password'|awk '{ print $5; }') && php bin/console doctrine:query:sql "UPDATE users SET password='$MAUTIC_ENCODED_PWD' where email = '$EMAIL'" && echo "'$EMAIL' got new Password: $CLIENTPWD"

Output:

(the last line contains the new Password for the email address)

1 Like

Would be great to have some best practices on the docs / KB if anyone would like to contribute!

I adapted @sfahrenkrog1 command for Mautic 5

EMAIL="admin@localhost.local" CLIENTPWD=$(openssl rand -hex 8) MAUTIC_ENCODED_PWD=$(php bin/console security:hash-password --no-interaction --ansi "$CLIENTPWD"|grep 'Password hash'|awk '{ print $3; }') && php bin/console doctrine:query:sql "UPDATE users SET password='$MAUTIC_ENCODED_PWD' where email = '$EMAIL'" && echo "'$EMAIL' got new Password: $CLIENTPWD"

HTH
Thanks @sfahrenkrog1 !!

1 Like