Меню

Допомога

8

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

Avatar
Ermin Trevisan

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.

1Коментар
Аватар
Відмінити
Avatar
Herve
-

great, thanks !

5Відповіді
36
Avatar
Ermin Trevisan
Найкраща відповідь
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!

7Коментарі
Аватар
Відмінити
Avatar
Juan Formoso
-

Great answer, thanks!

Avatar
Ermin Trevisan
-

@Lima: for me and many others it does work. So you may want to be more specific.

Avatar
Jaime Pedraza
-

smoooooth!!

Avatar
Mohamed Seddik El Behi
-

and what about odoo14???

Avatar
zhanghao章浩
-

try it on Odoo13,

select password from res_users where id=2; it's changed, but still can't login ....

Avatar
zhanghao章浩
-

and i use select * from res_users where id=2; between two database ,

found can't login reason is active ='f';

UPDATE res_users SET active='t'; now it's ok ,thanks

Avatar
Ayodeji Bello
-

What a great summary! Thank you.

0
Avatar
nickchacha@gmail.com
Найкраща відповідь

Worked like a cham. 

Thanks a lot for the post

Аватар
Відмінити
0
Avatar
Abdelkarim Mateos
Найкраща відповідь

A lot of thanks for you post.

I'm using Odoo 11 and work perfectly.


I can't upvote for ¢#@$&$@ karma system.


Best regards


Аватар
Відмінити
0
Avatar
Dominique Chabord
Найкраща відповідь

hi, thank you. How different are Odoo 9-10 and Odoo 11 ? Why do you specify two different syntaxes ?


Edit after your comments:

It seems to me the syntax may depend on python2 vs python3, independently from Odoo version.

I run Odoo 11 on python3 of course, but my script which changes the password uses python2 according to first syntax and no bug was reported up to now.

4Коментарі
Аватар
Відмінити
Avatar
Ermin Trevisan
-

I have just found out when I wanted to use the same syntax as for Odoo 9-10, that this did not work anymore for Odoo 11. After a lot of googling and trial and error, the syntax I have described did work. I was reading the available doc about CryptContext again and again, but I do not understand, why the first syntax ever worked, nor why this syntax did not work anymore nor why the new syntax works, that I have described. But I'm not a developer anyway...I'm just glad I was able to reset the password ;-)

Avatar
Ermin Trevisan
-

Example: from my understanding of the doc for passlib 1.7.0 I understood that it should be "setpw.hash('YourNewPassword'), but it did not work, and "setpw.encrypt" was just the result of trial and error.

Avatar
Ermin Trevisan
-

@Dominique: Yes, I'm aware that is depending on the Python version, but I wanted to make it easily understandable without knowing which Python version is used in which Odoo version. On my Ubuntu 16.04 LTS server I was not able to run the commands for Python 2 as mentioned for Odoo 9&10, therefore I came up with the separate version for Odoo 11.

Avatar
Ermin Trevisan
-

However I believe it is important to know how it works with Python 3.

-1
Avatar
Mohamed Elmi Hersi
Найкраща відповідь

Here is the best and shortcut way to get the password:

in the terminal:

type: 

1.sudo su postgres

2.psql 

you get like this:postgres=#

3. \connect your_db_name

you get this message:

You are now connected to database "your_db_name" as user "postgres".

4. type UPDATE res_users SET password='new_password' WHERE login = 'your_email';

Now you are set and good to go.

If you don't know your_email login, do the follwinng:

in step 4, just write the following:

your_db_name=# select id, login from res_users;

and you get:

id             login

----------------

1              publice

2              etc




Аватар
Відмінити