How to reset admin password in openfire?


安装好Openfire之后,忘记了管理员密码,怎么办?下面就来说说怎么重置Openfire的管理员密码。

在Openfire中,密码都是以加密形式存储在数据库中的(假定使用Mysql作为Openfire的用户和组的存储服务),登录openfire的后台数据库,通过下面的语句就能看到。

mysql> SELECT * FROM ofUser WHERE username='admin';
+----------+---------------+--------------------------------------------------+---------------+-------------------+-----------------+------------------+
| username | plainPassword | encryptedPassword                                | name          | email             | creationDate    | modificationDate |
+----------+---------------+--------------------------------------------------+---------------+-------------------+-----------------+------------------+
| admin    | NULL          | df8d8aa53e956defc1d83aa7612194fd610897dc271e475a | Administrator | admin@uniqueme.cn | 001248259126800 | 0                |
+----------+---------------+--------------------------------------------------+---------------+-------------------+-----------------+------------------+
1 row in set (0.00 sec)

mysql> _

encryptedPassword字段存储的就是管理员的密码,不过都已经变成16进制的字符了,但是plainPassword为什么是NULL呢?

如果你用过Openfire的User Import Export插件就会发现,在导入或者导出用户的数据的时候,密码都是明文,而且导入的用户,如果还没有登录过,密码都是明文存储在plainPassword字段的。登录过一次之后,plainPassword字段的密码被清空了,只留下了加密的密码。
利用这个特性,我们可以把encryptedPassword字段设置成NULL,然后给plainPassword字段重新设置明文密码。

mysql> UPDATE ofUser SET plainPassword='test123', encryptedPassword=NULL WHERE username='admin';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> SELECT * FROM ofUser WHERE username='admin';
+----------+---------------+-------------------+---------------+-------------------+-----------------+------------------+
| username | plainPassword | encryptedPassword | name          | email             | creationDate    | modificationDate |
+----------+---------------+-------------------+---------------+-------------------+-----------------+------------------+
| admin    | test123       | NULL              | Administrator | admin@uniqueme.cn | 001248259126800 | 0                |
+----------+---------------+-------------------+---------------+-------------------+-----------------+------------------+
1 row in set (0.00 sec)

mysql> _

好了。现在密码被重置了。我们去控制台试试,是不是登录成功了呢?再看一下数据库的状况。

mysql> SELECT * FROM ofUser WHERE username='admin';
+----------+---------------+--------------------------------------------------+---------------+-------------------+-----------------+------------------+
| username | plainPassword | encryptedPassword                                | name          | email             | creationDate    | modificationDate |
+----------+---------------+--------------------------------------------------+---------------+-------------------+-----------------+------------------+
| admin    | NULL          | dc94e8d99302d76ba02213b1f0c95088b58945b6110d5579 | Administrator | admin@uniqueme.cn | 001248259126800 | 0                |
+----------+---------------+--------------------------------------------------+---------------+-------------------+-----------------+------------------+
1 row in set (0.00 sec)mysql> _

如果你用的是Openfire 3.6.4,别忘了在更新了plainPassword和encryptedPassword之后,先重启一下Openfire服务,然后再登录。
为什么要重启再登录?这是Openfire 3.6.4的一个Bug,将在3.6.5中修复,详细请看:http://www.igniterealtime.org/issues/browse/JM-1537

Advertisements

3 thoughts on “How to reset admin password in openfire?

  1. 我正是这样做的。可是没有用。登录之后密码仍旧为明文。只有在控制台里修改密码之后,密码才会自动变成密文。

  2. 我用的是openfire 3.6.4 + MySQL,按照你的文章重置密码操作过后,数据库的plainPassword并没有被自动清空,encryptedPassword字段仍旧为空。你的这种方法基于哪个版本的openfire?

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s