How to Reset the Odoo Admin User Password: A Summary for different Odoo Versions

How do I reset the password of the admin user of my Odoo database? This is not the Odoo instance admin password (sometimes called “master password”), which is defined in the odoo.conf file.

Preliminary Remark: When you have migrated your database from an earlier version, the ID of your admin user may be different than suggested below. In this case you should check the ID of your admin user directly in the res_users table in your database.

 

Odoo 8.0:

Change the password directly in the Postgres Database, as it is saved in plain text:

~$  sudo su postgres
~$  psql
postgres=# \connect Your_Database_Name
You are now connected to database "Your_database_Name" as user "postgres"
YOurDatabase_Name=# update res_users set password='YourNewPassword' where id='1';

Odoo 9.0 and Odoo 10.0:

Create a hash and then change the hash in the Postgres database:

~$ python
>>> from passlib.context import CryptContext
>>> print CryptContext(['pbkdf2_sha512']).encrypt('YourNewPassword')
Copy the Hash created
Ctrl D
~$  sudo su postgres
~$  psql
postgres=# \connect Your_Database_Name
You are now connected to database "Your_database_Name" as user "postgres"
YOurDatabase_Name=# UPDATE res_users SET password='', password_crypt='YourCopiedHash' WHERE id=1;
YOurDatabase_Name=# \q

Odoo 11:

Create a hash using Python 3 and change the hash in the Postgres database:

~$ python3
>>> from passlib.context import CryptContext
>>> setpw = CryptContext(schemes=['pbkdf2_sha512'])
>>> setpw.encrypt('YourNewPassword')
Copy the Hash created
Ctrl D
~$  sudo su postgres
~$  psql
postgres=# \connect Your_Database_Name
You are now connected to database "Your_database_Name" as user "postgres"
YOurDatabase_Name=# UPDATE res_users SET password='', password_crypt='YourCopiedHash' WHERE id=1;

YOurDatabase_Name=# \q

Odoo 12 and Odoo 13:

Create a hash using Python 3 and change the hash in the Postgres database:

~$ python3
>>> from passlib.context import CryptContext
>>> setpw = CryptContext(schemes=['pbkdf2_sha512'])
>>> setpw.encrypt('YourNewPassword')
Copy the Hash created
Ctrl D
~$  sudo su postgres
~$  psql
postgres=# \connect Your_Database_Name
You are now connected to database "Your_database_Name" as user "postgres"
YOurDatabase_Name=# UPDATE res_users SET password='YourCopiedHash' WHERE id=2;
YOurDatabase_Name=# \q

Please be aware that since Odoo12 the Primary Key of the admin user has changed. The new ID is 2 (not 1 as in earlier versions) in a new install, if you have migrated your database from an earlier version, it might be even a higher number – please check your res_users table in the database first in this case.

Also there is no separate field “password_crypt” anymore.

Enjoy your saved life and don’t forget to upvote this little tutorial!

Source: How to Reset the Odoo Admin User Password: A Summary for different Odoo Versions | Odoo

Leave a Reply