背景:Nexus数据库使用嵌入式OrientDB Database
一、停止服务、备份
根据各自环境备份数据
二、重置数据库密码
1. 连接OrientDB Database
# 文件位于 nexus-3.35.0-02/lib/support/nexus-orient-console.jar
java -jar nexus-orient-console.jar
2. 连接database
执行 connect plocal:../sonatype-work/nexus3/db/security admin admin
连接数据库,根据环境调整路径
orientdb> connect plocal:/opt/sonatype-work/nexus3/db/security admin admin
Connecting to database [plocal:/opt/sonatype-work/nexus3/db/security] with user 'admin'...
2023-06-12 16:10:14:110 WARNI {db=security} Storage 'security' was not closed properly. Will try to recover from write ahead log... [OLocalPaginatedStorage]
2023-06-12 16:10:14:114 WARNI {db=security} Record com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OFuzzyCheckpointEndRecord{lsn=LSN{segment=4, position=47898}} will be skipped during data restore [OLocalPaginatedStorage]
2023-06-12 16:10:14:114 WARNI {db=security} Record OFuzzyCheckpointStartRecord{lsn=LSN{segment=4, position=47905}} com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OFuzzyCheckpointStartRecord{lsn=null, previousCheckpoint=LSN{segment=4, position=47858}} will be skipped during data restore [OLocalPaginatedStorage]
2023-06-12 16:10:14:114 WARNI {db=security} Record com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OFuzzyCheckpointEndRecord{lsn=LSN{segment=4, position=47945}} will be skipped during data restore [OLocalPaginatedStorage]OK
3. 重置密码为 admin123
update user SET password="$shiro1$SHA-512$1024$NE+wqQq/TmjZMvfI7ENh/g==$V4yPw8T64UQ6GfJfxYq2hLsVrBY8D1v+bktfOxGdt4b/9BthpWPNUy/CBk6V9iA0nHpzYzJFWO8v/tZFtES8CA==" UPSERT WHERE id="admin"
orientdb {db=security}> update user SET password="$shiro1$SHA-512$1024$NE+wqQq/TmjZMvfI7ENh/g==$V4yPw8T64UQ6GfJfxYq2hLsVrBY8D1v+bktfOxGdt4b/9BthpWPNUy/CBk6V9iA0nHpzYzJFWO8v/tZFtES8CA==" UPSERT WHERE id="admin"
Updated record(s) '1' in 0.018000 sec(s).
orientdb {db=security}>
orientdb {db=security}> select * from user_role_mapping where userID = "admin"
+----+-----+-----------------+------+-------+--------------------------------------+
|# |@RID |@CLASS |userId|source |roles |
+----+-----+-----------------+------+-------+--------------------------------------+
|0 |#15:0|user_role_mapping|admin |default|[nx-admin,shared,iss,rha,nx-anonymous]|
+----+-----+-----------------+------+-------+--------------------------------------+
1 item(s) found. Query executed in 0.027 sec(s).
4. 检查roles
检查roles 是否包含 nx-admin,如果没有执行如下
INSERT INTO user_role_mapping (userId, source, roles) VALUES ('admin', 'default', 'nx-admin')
or
update user_role_mapping set roles = ["nx-admin"] where userID = "admin"
所有手段都不行,重置default security realms
delete from realm
5. 退出,并修改文件权限
chown -R nexus:nexus sonatype-work/nexus3/db/security/*
三、重启服务
重启服务后,使用默认账户 admin / admin123 登录。
网友评论