Restore Odoo Admin Password

Change Your Odoo Admin Password From the Command Line

Once you’re in your server’s terminal, switch the current user to odoo:

sudo su odoo 

Enter the Python shell:

python3

Import the necessary hashing module:

from passlib.context import CryptContext

Encrypt the new password using the PBKDF2 SHA512 scheme and show the result:

print(CryptContext(schemes=['pbkdf2_sha512']).encrypt('your_new_password'))

Note: change your_new_password to whatever you want your new password to be. The value should remain wrapped in single quotation marks.

You should see a long string of text that looks similar to this one: 

$pbkdf2-sha512$10001$0dr7v7eWUmptrfW.9z6HkA$w9j9AMVmKAP17OosCqDxDv2hjsvzlLpF8Rra8I7p/b5746rghZ8WrgEjDpvXG5hLz1UeNLzgFa81Dr/bx.2b7hg

Copy (or write down) your unique text string. You will need it later.

When you’re done, exit the Python shell.

exit()

Deactivate the virtual environment.

deactivate

Exit the odoo user:

exit

Switch to the postgres Linux user:

sudo su - postgres

Connect to the PostgreSQL (Odoo’s database) shell to modify the database.

psql

If you don't remember the name of your Odoo database (you set it when you created your Admin user), use the following command to list all the databases and accociated users. 

\l

Search for the odoo user and the associated database name. The latter is the name you need.

Once you know the database name, connect to the Odoo database:

\c test

Note: change test to the actual name of your Odoo database.

Now we need to change the password of the Admin user. If you don’t remember the user’s email value (which is used as the login), execute the following command to get a list of all user logins.

select login from res_users;

Find your email in that list.

Finally, change the password value of the Admin user to the newly generated one:

update res_users set password = 'new_hashed_password' where login = 'your@email.com';

Note: change your@email.com to your actual email value. Change new_hashed_password to that long string of text that you copied/wrote down earlier. Both values should remain wrapped in single quotation marks.

Exit the database:

\q

Exit  user:

exit

 

root@localhost:~# sudo su odoo
odoo@localhost:/root$ python3
>>> from passlib.context import CryptContext
>>> print(CryptContext(schemes=['pbkdf2_sha512']).encrypt('your_new_password'))
<stdin>:1: DeprecationWarning: the method passlib.context.CryptContext.encrypt() is deprecated as of Passlib 1.7, and will be removed in Passlib 2.0, use CryptContext.hash() instead.
$pbkdf2-sha512$10001$0dr7v7eWUmptrfW.9z6HkA$w9j9AMVmKAP17OosCqDxDv2hjsvzlLpF8Rra8I7p/b5746rghZ8WrgEjDpvXG5hLz1UeNLzgFa81Dr/bx.2b7hg
>>> exit()
odoo@localhost:/root$ exit
exit
root@localhost:~# sudo su - postgres
postgres@localhost:~$ psql
postgres=# \c dbname
dbname=# update res_users set password = '$pbkdf2-sha512$10001$0dr7v7eWUmptrfW.9z6HkA$w9j9AMVmKAP17OosCqDxDv2hjsvzlLpF8Rra8I7p/b5746rghZ8WrgEjDpvXG5hLz1UeNLzgFa81Dr/bx.2b7hg' where login = 'adminemail@gmail.com';
UPDATE 1
kitchen=# \q
postgres@localhost:~$ exit
logout
root@localhost:~#

 

  • 0 Usuários acharam útil
Esta resposta lhe foi útil?

Artigos Relacionados

Security and Protection for Super Global Host

Everyone wants to secure system login in to their website or server and in today’s world it is...

Security of website

Security While owning a website, security of the same should be your primary motive. Even if...

Restoring files and databases with Server Rewind

If you delete or change any files or databases by mistake and want to get back it again then you...

How to protect your website from spamming or hacking?

Some times you saw over 3,000 or more emails coming from a script within any directory of your...

How to use SSH to access your account

By using SSH you can login your hosting Account without using Cpanel. If your Computer or Laptop...

Powered by WHMCompleteSolution