-
Notifications
You must be signed in to change notification settings - Fork 53
Configure existing database
F43nd1r edited this page Mar 28, 2024
·
6 revisions
This tutorial shows how to change the default setup to use your own database instead of one inside docker.
[mysqld]
log-bin-trust-function-creators = 1
CREATE DATABASE acrarium CHARACTER SET utf8mb4;
CREATE USER acrarium IDENTIFIED BY '[[secure_password]]';
GRANT ALL PRIVILEGES ON acrarium.* TO acrarium@localhost identified by '[[secure_password]]';
Follow 2.a if using docker, 2.b otherwise.
Use the default docker-compose from Step 2 of the Setup guide, removing the database
service.
Then add
extra_hosts:
host.docker.internal: host-gateway
to the acrarium
service if your database is running on localhost.
And adjust your environment:
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://host.docker.internal:3306/acrarium?useSSL=false&allowPublicKeyRetrieval=true&useLegacyDatetimeCode=false&serverTimezone=UTC
SPRING_DATASOURCE_USERNAME: acrarium
SPRING_DATASOURCE_PASSWORD: [[secure_password]]
# spring.datasource.url=jdbc:mysql://<sql host>:<sql port>/<database name>?useSSL=false&allowPublicKeyRetrieval=true&useLegacyDatetimeCode=false&serverTimezone=UTC, e.g.
spring.datasource.url=jdbc:mysql://localhost:3306/acrarium?useSSL=false&allowPublicKeyRetrieval=true&useLegacyDatetimeCode=false&serverTimezone=UTC
# spring.datasource.username=<sql user name>, e.g.
spring.datasource.username=acrarium
# spring.datasource.password=<sql user password>, e.g.
spring.datasource.password=[[secure_password]]