从早期版本迁移数据库后,管理员用户的ID可能不同于以下建议的ID。 在这种情况下,您应该直接在数据库的res_users表中检查admin用户的ID。
Odoo 8.0:
直接在PostgreSQL数据库中修改,以明文保存密码:
~$ 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:
创建一个HASH密码,然后更新到PostgreSQL数据库:
~$ 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:
使用Python3创建Hash密码,然后更新到PostgreSQL数据库:
~$ 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:
使用Python3创建Hash密码,然后更新到PostgreSQL数据库:
~$ 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
请注意,自Odoo12起,管理员用户的主键已更改。 在新安装中,新ID为2(而不是早期版本中的1),如果您是从早期版本中迁移数据库的,则该ID甚至可能更高-在这种情况下,请首先检查数据库中的res_users表。
另外,也没有单独的字段“ password_crypt”。