How to Reset an Admin Password in Perfex CRM directly into MYSQL
If you’ve forgotten the admin password for your Perfex CRM and need to reset it using MYSQL, follow these steps to update the password directly in the database using Docker and bcrypt.
Prerequisites
- Docker and Docker Compose installed
- Access to your Docker containers
- Python installed on your machine
Steps
- Identify the MySQL Container: First, list all running containers to find the name or ID of your MySQL container:
docker ps
2. Access the MySQL Container: Get a shell inside the MySQL container:
docker exec -it <mysql_container_name_or_id> bash
- Replace
<mysql_container_name_or_id>
with the actual name or ID of your MySQL container.3.
3. Log into the MySQL Database: Log into the MySQL database using the MySQL command line client:
mysql -u root -p
- Enter the MySQL root password when prompted.
4. Select the Database: Use the correct database for Perfex CRM:
USE perfexcrm;
4. Generate a Bcrypt Hash for the New Password: Use Python (a google colab will be easy) to generate a bcrypt hash for your new password. First, install the bcrypt library if you haven’t already:
pip install bcrypt
5. Create and run a Python script (generate_bcrypt.py
) with the following content:
import bcrypt
# Replace 'example_pass' with your desired password
password = b"example_pass"
hashed = bcrypt.hashpw(password, bcrypt.gensalt())
print(hashed.decode())
6. Update the Admin User’s Password in MySQL: Use the generated bcrypt hash to update the password for the admin user:
UPDATE tblstaff SET password = '<bcrypt_hash>' WHERE email = 'email@gmail.com'
7. Replace <bcrypt_hash>
with the actual bcrypt hash you generated using python and 'email@gmail.com'
with the email of the admin user.
8. Exit the MySQL Client and Container: Exit the MySQL client:
EXIT;
Following these steps will reset the admin password for your Perfex CRM using Docker and bcrypt, allowing you to regain access.