Tutorial, Ubuntu

How to Reset Admin Password in Mautic in Docker Environment

Lost my admin password and / or something went wrong. Anyways, I figured I have to learn how to do to be a good admin anyways, so might as well go through the pain for the learning and blog it for the rest of you to benefit from….

  1. Go to your Docker folder where your docker-compose.yml file is (if you installed it that way).
  2. sudo nano docker-compose.yml
  3. go down to your database root password and copy it to clipboard. You set this while you were making docker-compose file and you will now copy it to clipboard with control + shift + c
  4. dial in this command, or adjust if your container name is different:

sudo docker exec -it mautic mysql -uroot -p

  1. paste in the password when prompted iwth control shift v

BUT – WAIT.. WHAT A FAIL!

If somehow you were able to get in directly with that command above without the ‘can’t connect’ error, great, otherwise, continue on with me below…

Unfortunately I got this error time and time and time again for literally 4 hours of trying:

`

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Finally I found this link

and right at the bottom was the solution – the least voted comment – right at the very bottom, of course…

mysql -h "$container_ip" -P 3307 --protocol=tcp -u root -p

So, what I had to do, to access MySQL in this Docker / Mautic environment was this:

  1. Find out my actual DOCKER network IP address with this command:

docker inspect mysqlcontainername | grep Gateway

So in this mautic environment my command looked like this:

docker inspect mautic | grep Gateway

Response back was a "Gateway": "172.15.0.1" kind of response.

  1. Copy the gateway IP to clipboard
  2. Drill into the container to create a bash script inside Mautic:

sudo docker exec -it mautic bash

  1. Run the mysql command entering the gateway IP as the host with the -h flag:

mysql --protocol=tcp -u root -p -h 172.15.0.1

You should now be inside MYSQL for Mautic, see the MySQL command prompts, and be able to start fixing the admin password.

Now we will follow this blog which is exhaustive and gives a good play-by-play

  1. show databases;

2. use mautic4 (or whatever it’s called for you)

3. show tables; – this is to confirm 100% what the ‘users’ table is called as mine ended up with the name mautic4users instead of just ‘users’. Docker must append that to the front of the usual names…

On the next command, make sure your ‘users’ part is adjusted to whatever the correct name is for that. Here is the tutorials command:

UPDATE users SET password = "$2y$13$VkE7UjFetqAM13oT4v/VYOfRCGrJ4hbr0zuwRZo6KVfDnNb16WFwy" WHERE id=1;

Here is how I updated mine for my table:

UPDATE mautic4users SET password = "$2y$13$VkE7UjFetqAM13oT4v/VYOfRCGrJ4hbr0zuwRZo6KVfDnNb16WFwy" WHERE id=1;

Now go back to your mautic instance and try logging in with user ‘admin’ (assuming that was your default user” and password madmin

Boom. I’m in.

Thanks to all in the links above for their contributions and help!

Of course, don’t forget to change your Mautic admin password from ‘madmin’ back to something useful and strong…

Tagged , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *