侧边栏壁纸
  • 累计撰写 30 篇文章
  • 累计创建 35 个标签
  • 累计收到 4 条评论

nacos 密码忘记

GoDan
2022-05-17 / 0 评论 / 0 点赞 / 154 阅读 / 3,118 字 / 正在检测是否收录...
温馨提示:
本文最后更新于 2022-05-17,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

由于第一次部署没有使用mysql单机模式;而是用nacos自带的库
需使用apache提供的Derby工具进行操作

下载地址

https://db.apache.org/derby/derby_downloads.html
选择对应的jdk版本下载
我这里是jdk8

root@aliyun-beijing-test-01:/usr/local/src# wget https://dlcdn.apache.org//db/derby/db-derby-10.14.2.0/db-derby-10.14.2.0-bin.tar.gz
root@aliyun-beijing-test-01:/usr/local/src# tar -zxvf db-derby-10.14.2.0-bin.tar.gz

查看nacos 数据库目录

# 找到下面的参数
-Dnacos.home=/usr/local/nacos/distribution/target/nacos-server-2.1.0/nacos
# 查看进程
root@aliyun-beijing-test-01:/usr/local/src# ps -ef | grep nacos
/usr/local/jdk/bin/java -Djava.ext.dirs=/usr/local/jdk/jre/lib/ext:/usr/local/jdk/lib/ext  -Xms512m -Xmx512m -Xmn256m -Dnacos.standalone=true -Dnacos.member.list= -Xloggc:/usr/local/nacos/distribution/target/nacos-server-2.1.0/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dloader.path=/usr/local/nacos/distribution/target/nacos-server-2.1.0/nacos/plugins/health,/usr/local/nacos/distribution/target/nacos-server-2.1.0/nacos/plugins/cmdb,/usr/local/nacos/distribution/target/nacos-server-2.1.0/nacos/plugins/selector -Dnacos.home=/usr/local/nacos/distribution/target/nacos-server-2.1.0/nacos -jar /usr/local/nacos/distribution/target/nacos-server-2.1.0/nacos/target/nacos-server.jar  --spring.config.additional-location=file:/usr/local/nacos/distribution/target/nacos-server-2.1.0/nacos/conf/ --logging.config=/usr/local/nacos/distribution/target/nacos-server-2.1.0/nacos/conf/nacos-logback.xml --server.max-http-header-size=524288

连接数据库更新密码

# 先关闭nacos才可以连接操作
root@aliyun-beijing-test-01:/usr/local/src# cd /usr/local/nacos/distribution/target/nacos-server-2.1.0/nacos/bin/
bash shutdown.sh
# 使用Derby工具进行操作
root@aliyun-beijing-test-01:/usr/local/src# cd /usr/local/src/db-derby-10.14.2.0-bin/bi
root@aliyun-beijing-test-01:/usr/local/src/db-derby-10.14.2.0-bin/bin# ./ij
ij version 10.14
ij> connect 'jdbc:derby:/usr/local/nacos/distribution/target/nacos-server-2.1.0/nacos/data/derby-data;create=true'
ij> update NACOS.USERS set PASSWORD='$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu' where USERNAME='nacos';
1 row inserted/updated/deleted

启动nacos,重新登录

更新后的账户密码为nacos/nacos

root@aliyun-beijing-test-01:/usr/local/src/db-derby-10.14.2.0-bin# cd /usr/local/nacos/distribution/target/nacos-server-2.1.0/nacos/bin/
root@aliyun-beijing-test-01:/usr/local/nacos/distribution/target/nacos-server-2.1.0/nacos/bin# bash startup.sh -m standalone

image-1652768988533

问题

连接后查看报错

root@aliyun-beijing-test-01:/usr/local/src/db-derby-10.14.2.0-bin/bin# ./ij
ij version 10.14
ij> connect 'jdbc:derby:/usr/local/nacos/distribution/target/nacos-server-2.1.0/nacos/data/derby-data;create=true'
> show tables;
ERROR XJ040: Failed to start database '/usr/local/nacos/distribution/target/nacos-server-2.1.0/nacos/data/derby-data' with class loader sun.misc.Launcher$AppClassLoader@5e2de80c, see the next exception for details.
ERROR XSDB6: Another instance of Derby may have already booted the database /usr/local/nacos/distribution/target/nacos-server-2.1.0/nacos/data/derby-data.
ij> show databases;
IJ ERROR: Unable to establish connection
ij>

是因为没有关闭nacos,需要先将nacos服务停止后连接

0

评论区