+4 votes
in CMS Tips by (40.5k points)
I migrated my website to a new server and upgraded PHP to 7.3. Now I am not able to access the admin panel using admin id and password. It says that my password is wrong. I tried to reset the password by clicking on the link "I forgot my password". Although it says the code was sent to my email address, I do not see any email from my Q2A website.

Is there any way to update the password in the database?

1 Answer

+2 votes
by (349k points)
selected by
 
Best answer

Here are the steps to change the password of a user in the database:

1. If your VPS or computer has Linux OS, open the terminal and type "php -a" to run PHP interactively.

$ php -a
Interactive mode enabled

2. Once the interactive mode is enabled. Type "echo password_hash('my_new_pass', 1);", where my_new_pass is your new password.

php > echo password_hash('my_new_pass', 1);
$2y$10$5To6aqjufDeBpGJZtyCNWuRf.MKoJZNZXEH1dXA8TfhMHVppJys46

3. Copy the hash value of your password generated above and access your Q2A database from PHPMYADMIN or terminal.

4. Run the following SQL:

UPDATE qa_users
SET passhash = 'hash_value_of_password'
WHERE userid = YOUR_USER_ID;

Where hash_value_of_password is the value from step 2. Now you should be able to log in using the new password.


...