Chandan Rajpurohit

An Artist With Technical Skills

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.

Keycloak
Keycloak – https://www.keycloak.org
https://chandanrajpurohit.dev/2021/01/03/what-is-keycloak/

Create keycloak database in MySQL

Open cmd/ terminal and connect to your MySQL Server using your root MySQL credentials.

mysql -u root -p

Above 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/keycloak

Next, go to the bin directory: cd keycloak-22.0.1/bin/

Start the Keycloak Server:
In Windows
.\kc.bat start-dev

In Linux / Ubuntu / Unix
$ ./kc.sh start-dev

Go 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.

%d bloggers like this: