It is a general thing to forget the password and in case of Odoo, it is even more difficult to get it back from the backend PSQL query because it uses the concept of the password encryption which is good practics.
In previous versions of Odoo because it was saved in plain text format and hence it was easy for attackers to take over your database and get every user’s password. If you recover your database, the hacker still has access to your user’s account. But from v8 onwards and now in v11 the passwords are stored in an encrypted format.
So what happens if you forget your password? Well so far I have had no success in finding a solution for it but just now I used a trick and it worked.
So what I did in a nutshell was:
- Register a new user from web frontend and give it an easy password
- Now use PG Admin or PSQL to login to the database and copy the password of this new user to the admin user
- Voila, it worked.
Now let me explain this in detail.
You can do step 1 by going to the web frontend using http://<domainOrIPAddress>/web/register. Even if it fails on SMTP send, it will store the user and the password in the database.
Now go to the command line (this is what I used and the steps will be similar and easier on PG Admin interface).
Login as postgres user:
sudo su postgres;
Switch to the database in question:
List all users with their passwords:
select * from res_users;
Now copy the password and use it in the following command:
update res_users set password_crypt = ‘<copiedPasswordFromAbove>’ where id = ‘1’;
That’s it. Go and login with username admin and password you used to register the user in the first place.
If it helped you… don’t forget to share this post on your wall. It may be helpful to someone else.