In this post I show how to reset the Liferay admin password. The official wiki suggests to manually edit the database (User_ table) to reset the administrator password. By default the encryption algorithm to encrypt passwords is SHA-1. Digested passwords are encoded and stored in the database via base64 or hex encoding (default base64). To check this, see the portal.properties file in portal-impl.jar (or the portal-ext.properties file for extension environments). The default values are shown below.
# Set the following encryption algorithm to encrypt passwords. The default # algorithm is SHA (SHA-1). If set to NONE, passwords are stored in the # database as plain text. The SHA-512 algorithm is currently unsupported. # #passwords.encryption.algorithm=BCRYPT #passwords.encryption.algorithm=UFC-CRYPT #passwords.encryption.algorithm=MD2 #passwords.encryption.algorithm=MD5 #passwords.encryption.algorithm=NONE passwords.encryption.algorithm=SHA #passwords.encryption.algorithm=SHA-256 #passwords.encryption.algorithm=SHA-384 #passwords.encryption.algorithm=SSHA # # Digested passwords are encoded via base64 or hex encoding. The default is # base64. # passwords.digest.encoding=base64 #passwords.digest.encoding=hex
Prior to update the database make sure that you have a backup copy of your data. Follows my application stack.
SO: CentOS 6.4 64_bit
Liferay: 6.1.2-GA2
Oracle: 11.2.0.3
1. Find administration’s role ID
SQL> select roleid, name from role_ where name = 'Administrator'; ROLEID NAME ---------- --------------------------------------------------------------------------- 10161 Administrator
2. Find users with administration’s role
SQL> select * from users_roles; USERID ROLEID ---------- ---------- 10158 10162 10196 10161 10196 10164 10196 10165
3. Find admin’s credentials (id 10196)
SQL> select userId, screenName, password_ from user_ where userid=10196; USERID SCREENNAME PASSWORD_ ---------- --------- -------------- 10196 admin vQ2A4fJEfm9p240OmdPcrfz1vnU=
4. Update the base64 password value
# plain-text: admin # SHA-1 hex: d033e22ae348aeb5660fc2140aec35850c4da997 # SHA-1 base64: 0DPiKuNIrrVmD8IUCuw1hQxNqZc= (stored in the DB)
SQL> update user_ set password_='0DPiKuNIrrVmD8IUCuw1hQxNqZc='where userId=10196; SQL> select userId, screenName, password_ from user_ where userid=10196; USERID SCREENNAME PASSWORD_ ---------- -------- -------------- 10196 admin 0DPiKuNIrrVmD8IUCuw1hQxNqZc=