安装Keycloak并启动服务(macOS)

前提:电脑已经安装Java 17+

1、下载Keycloak

2、下载完后解压缩,使用文本编辑器修改配置文件(keycloak/conf/keycloak.conf)

Basic settings for running in production. Change accordingly before deploying the server.

Database

The database vendor.

#db=postgres

db=mysql

The username of the database user.

db-username=root

The password of the database user.

db-password=123456

The full database JDBC URL. If not provided, a default URL is set based on the selected database vendor.

#db-url=jdbc:postgresql://localhost/keycloak

db-url=jdbc:mysql://localhost:3306/keycloak

Observability

If the server should expose healthcheck endpoints.

health-enabled=true

If the server should expose metrics endpoints.

metrics-enabled=true

HTTP

The file path to a server certificate or certificate chain in PEM format.

#https-certificate-file=${kc.home.dir}/conf/server.crt.pem

The file path to a private key in PEM format.

#https-certificate-key-file=${kc.home.dir}/conf/server.key.pem

The proxy address forwarding mode if the server is behind a reverse proxy.

#proxy=reencrypt

Do not attach route to cookies and rely on the session affinity capabilities from reverse proxy

#spi-sticky-session-encoder-infinispan-should-attach-route=false

Hostname for the Keycloak server.

hostname=localhost

3、在命令窗口cd到解压后的keycloak目录,然后使用下面的指令创建一个临时的管理员账号

bin/kc.sh bootstrap-admin user

4、根据提示输入用户名和密码,密码随便设,临时账号后面还要删掉

5、启动keycloak服务

bin/kc.sh start-dev --http-port 8181

6、启动成功会看到下面的信息

Keycloak 26.3.1 on JVM (powered by Quarkus 3.20.1) started in 35.660s. Listening on: http://0.0.0.0:8181.

7、在浏览器输入

http://localhost:8181

8、使用刚刚输入的临时账号密码登录,进入用户页面添加新用户

9、添加用户后在 Credentials 页面设置密码

10、在 Role mapping 页面分配权限

11、退出临时管理账号,使用刚刚创建的账号登录,顶部就不会显示下面这段英文了

You are logged in as a temporary admin user. To harden security, create a permanent admin account and delete the temporary one.

12、删除临时账号

相关推荐
至此流年莫相忘3 分钟前
Spring 依赖注入三剑客:@Autowired、@Resource 与 @RequiredArgsConstructor 深度对比与实战指南
java·数据库·spring
零陵上将军_xdr15 分钟前
为什么DCL单例要加volatile?——CPU乱序执行与内存屏障
java·linux
shushangyun_28 分钟前
批发商城系统源码多少钱?2026最新报价一览
java·开发语言·人工智能·spring·spring cloud
cfm_291430 分钟前
JVM深度详解:Class常量池、运行时常量池、字符串常量池、包装类对象池
java·jvm
JAVA面经实录91730 分钟前
高频算法面试题
java·计算机网络·算法·面试
影视飓风TIM30 分钟前
从C++引用到类封装:底层视角拆解核心语法与面试考点
java·开发语言
天天爱吃肉82181 小时前
豆包 vs DeepSeek API 对比分析报告
android·java·大数据·开发语言·功能测试·嵌入式硬件·汽车
柏舟飞流1 小时前
Spring Boot + Spring Security + RBAC:从登录鉴权到权限模型设计
java·spring boot·spring
AC赳赳老秦1 小时前
OpenClaw + 飞书多维表格:自动同步数据、生成统计图表、触发自动化任务
java·大数据·python·缓存·自动化·deepseek·openclaw
CS_SKILL1 小时前
吉比特 C++ 实习一面面经:一轮把 C++、容器、并发、排序和网络全扫了一遍
java·开发语言·校招面经·实习面经·技术面经·吉比特校招