nexus3 的 admin 账号密码忘记了,需要重置。
1 | nexus 基于 docker-compose 部署,版本 nexus3.26 |
由于 nexus 是基于 docker 部署,后面我们需要进入容器中执行相关命令,所以此处不能直接使用 docker stop xxx
来关闭服务。需要进入到容器内部来关闭 nexus 服务。
1 | # 进入 docker 容器内,注意,此处使用 root 用户,否则后续命令会无权限 |
说明:此处 docker 容器中 nexus 服务关闭的情况可能各不相同,此处找到了镜像原始 dockerfile,从中服务启动时执行的路径,推测出其关闭服务的命令。启动服务命令是 CMD ["/opt/sonatype/nexus/bin/nexus", "run"]
,则尝试使用 /opt/sonatype/nexus/bin/nexus stop
来关闭服务。
参考: https://github.com/sonatype/docker-nexus3/blob/main/Dockerfile
1 | java -jar $NEXUS_HOME/lib/support/nexus-orient-console.jar |
需要根据 nexus 各自的安装情况执行上述命令。
参考: https://support.sonatype.com/hc/en-us/articles/115002930827-Accessing-the-OrientDB-Console
1 | # 查看 db 目录,根据实际情况查找到目录 |
1 | # 查看 admin 用户信息 |
注意:为了方便,此处先临时将密码更新为 admin123
。
若要退出 OrientDB 控制台,输入 exit;
即可退出。
1 | orientdb {db=security}> exit; |
1 | # 启动服务 |
使用 admin:admin123
帐密来登录 nexus 服务,验证是否调整正确。若确认调整成功,建议及时使用更复杂的密码替换临时密码 admin123
。
Error creating history file java.io.IOException: Permission denied at java.io.UnixFileSystem.createFileExclusively(Native Method) at java.io.File.createNewFile(File.java:1012) at
一开始使用 docker exec -it nexus3 /bin/bash
进入容器,执行进行 OrientDB 命令时,会报无权限,且无法使用 sudo su
切换用户。使用 docker exec -u root -it nexus3 /bin/bash
即可。
参考: https://gist.github.com/marcelmaatkamp/123e8793e07a72a382d8d0e8d66bbd8f?permalink_comment_id=3276537
How to reset a forgotten admin password in Sonatype Nexus Repository 3
Nexus3.X 忘记 admin 密码找回