Nacos修改密码
1.前言:
得知nacos在mysql数据库中的加密方式使用的是Bcrypt机密方式,可以使用一下网站加密想要的密码:https://www.jisuan.mobi/p163u3BN66Hm6JWx.html
#原来的密码: nacos #加密后是:(在mysql中可以看见) $2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu #现在修改密码为:Test2023% #加密后是: $2a$10$5g3zlOU8NvvVDfFDnz2EMOK7rzn80BXsyBH5kiReCXXCb7kBFxqea
1.2 实时修改:
1.登录nacos的数据库
mysql -uroot -p mysql> use nacos; #查看原始的加密密码 mysql> select * from users; +----------+--------------------------------------------------------------+---------+ | username | password | enabled | +----------+--------------------------------------------------------------+---------+ | nacos | $2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu | 1 | +----------+--------------------------------------------------------------+---------+ 1 row in set (0.00 sec) #修改密码的值 mysql> UPDATE users SET password='$2a$10$5g3zlOU8NvvVDfFDnz2EMOK7rzn80BXsyBH5kiReCXXCb7kBFxqea' WHERE username='nacos'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 #再次查看 mysql> select * from users; +----------+--------------------------------------------------------------+---------+ | username | password | enabled | +----------+--------------------------------------------------------------+---------+ | nacos | $2a$10$5g3zlOU8NvvVDfFDnz2EMOK7rzn80BXsyBH5kiReCXXCb7kBFxqea | 1 | +----------+--------------------------------------------------------------+---------+ 1 row in set (0.00 sec)
去浏览器上重新登录nacos平台,需要使用新的密码
1.3修改默初始密码
想要让新建的nacos直接使用新的密码,可以直接先修改nacos-mysql.sql文件后,再导入mysql
vim nacos-mysql.sql #将下面这行: INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE); #修改为: INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$5g3zlOU8NvvVDfFDnz2EMOK7rzn80BXsyBH5kiReCXXCb7kBFxqea ', TRUE); #即可