How To Configure Keycloak With MySQL Database?
- Chandan Rajpurohit
- Aug 7, 2023
- 1 min read
Updated: 6 days ago
Keycloak is an Open Source Identity and Access Management. Keycloak provides Single-Sign On, Identity brokering and Social Login, user federation, strong authentication, user management, fine-grained authorization, and more. Let’s see how we can configure keycloak with MySQL database.
Create keycloak database in MySQL
Open cmd/ terminal and connect to your MySQL Server using your root MySQL credentials.
mysql -u root -pAbove command will ask password for the MySQL root user.
CREATE DATABASE keycloak;
CREATE USER 'keycloak'@'localhost' IDENTIFIED BY 'keycloak';
GRANT ALL PRIVILEGES ON keycloak.* TO 'keycloak'@'localhost';Configure Keycloak to use MySQL Database
Go to the conf directory of the Keycloak Server.
Open the keycloak.conf file with a text editor.
Uncomment and update the following properties in conf/keycloak.conf file:
db=mysql
db-username=keycloak
db-password=keycloak
db-url=jdbc:mysql://localhost:3306/keycloakNext, go to the bin directory: cd keycloak-22.0.1/bin/ and start the Keycloak Server
In Windows
.\kc.bat start-devIn Linux / Ubuntu / Unix
$ ./kc.sh start-devGo to the browser and open http://localhost:8080. You should see the Keycloak Admin Console.
Thank you for reading this article, I really appreciate it. If you have any questions, feel free to leave a comment.
Comments