所以,我在这里按照这个教程来设置一个MySQL数据库的keycloak,老实说,我只是没有取得任何进展!已经两天了,我完全卡住了。
我正在遵循本指南,并完全按照指南中的步骤进行操作:
创建Docker网络:
docker network create keycloak-network
在此网络内启动mysql
:
docker run --name mysql -d --net keycloak-network -e MYSQL_DATABASE=keycloak -e MYSQL_USER=keycloak -e MYSQL_PASSWORD=password -e MYSQL_ROOT_PASSWORD=root-password mysql
启动keycloak
:
docker run -p 8080:8080 --name keycloak --net keycloak-network -e KEYCLOAK_LOGLEVEL=DEBUG -e KEYCLOAK_USER=kc-admin -e KEYCLOAK_PASSWORD=admin jboss/keycloak
另外,在mysql上,我运行了以下命令:
CREATE SCHEMA keycloak;
CREATE USER 'keycloak'@'localhost' IDENTIFIED BY 'keyCloak@Idp123';
GRANT ALL PRIVILEGES ON *.* TO 'keycloak'@'localhost';
FLUSH PRIVILEGES;
SHOW GRANTS FOR 'keycloak'@'localhost'
给出以下输出:
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `keycloak`@`localhost` |
| GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,FLUSH_OPTIMIZER_COSTS,FLUSH_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,GROUP_REPLICATION_ADMIN,INNODB_REDO_LOG_ARCHIVE,INNODB_REDO_LOG_ENABLE,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SHOW_ROUTINE,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `keycloak`@`localhost` |
但是,当keycloak容器启动时,我在日志中看到了以下内容:
Caused by: java.sql.SQLException: Access denied for user 'keycloak'@'172.18.0.3' (using password: YES)
at com.mysql.jdbc@8.0.22//com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.jdbc@8.0.22//com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.jdbc@8.0.22//com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.jdbc@8.0.22//com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
at com.mysql.jdbc@8.0.22//com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
at com.mysql.jdbc@8.0.22//com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
at com.mysql.jdbc@8.0.22//com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
所以我想好吧,也许IP地址是一个因素,所以我再次运行SQL命令为'keycloak'@'172.18.0.3'
,但这个问题仍然存在!我还可以如何让我的keycloak连接MySQL数据库?
1条答案
按热度按时间kx1ctssn1#
您应该不需要手动定义用户。您需要为数据库和keycloak之间的连接指定更多环境,例如DB_VENDOR。示例:https://github.com/keycloak/keycloak-containers/blob/master/docker-compose-examples/keycloak-mysql.yml
对于MYSQL;
MYSQL用户名、MYSQL密码、MYSQL数据库、MYSQL根密码
用于Keycloak;
数据库_供应商、数据库_地址、数据库_端口、数据库_用户、数据库_密码、数据库_数据库、数据库_方案、密钥锁_用户、密钥锁_密码