-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.sql
25 lines (22 loc) · 1.23 KB
/
init.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
-- init.sql
-- Create database if it doesn't exist
CREATE DATABASE IF NOT EXISTS db_user;
CREATE DATABASE IF NOT EXISTS db_order;
CREATE DATABASE IF NOT EXISTS db_cart;
CREATE DATABASE IF NOT EXISTS db_payment;
CREATE DATABASE IF NOT EXISTS db_inventory;
CREATE DATABASE IF NOT EXISTS db_keycloak;
-- Create users and grant permissions
CREATE USER IF NOT EXISTS 'user_db_user'@'%' IDENTIFIED BY 'password_user_db_user';
CREATE USER IF NOT EXISTS 'user_db_order'@'%' IDENTIFIED BY 'password_user_db_order';
CREATE USER IF NOT EXISTS 'user_db_cart'@'%' IDENTIFIED BY 'password_user_db_cart';
CREATE USER IF NOT EXISTS 'user_db_payment'@'%' IDENTIFIED BY 'password_user_db_payment';
CREATE USER IF NOT EXISTS 'user_db_inventory'@'%' IDENTIFIED BY 'password_user_db_inventory';
CREATE USER IF NOT EXISTS 'user_db_keycloak'@'%' IDENTIFIED BY 'password_user_db_keycloak';
GRANT ALL PRIVILEGES ON db_user.* TO 'user_db_user'@'%';
GRANT ALL PRIVILEGES ON db_order.* TO 'user_db_order'@'%';
GRANT ALL PRIVILEGES ON db_cart.* TO 'user_db_cart'@'%';
GRANT ALL PRIVILEGES ON db_payment.* TO 'user_db_payment'@'%';
GRANT ALL PRIVILEGES ON db_inventory.* TO 'user_db_inventory'@'%';
GRANT ALL PRIVILEGES ON db_keycloak.* TO 'user_db_keycloak'@'%';
FLUSH PRIVILEGES;