-- autoflow DB 및 사용자 생성 (MariaDB/MySQL)
-- 실행: root 또는 DB 관리자로 실행
-- 예: mysql -u root -p < init-autoflow-db.sql
--     또는 mysql -u root -p 후 소스 또는 붙여넣기

CREATE DATABASE IF NOT EXISTS autoflow
  CHARACTER SET utf8mb4
  COLLATE utf8mb4_unicode_ci;

CREATE USER IF NOT EXISTS 'autoflow'@'localhost' IDENTIFIED BY 'autoflow';
CREATE USER IF NOT EXISTS 'autoflow'@'%' IDENTIFIED BY 'autoflow';

GRANT ALL PRIVILEGES ON autoflow.* TO 'autoflow'@'localhost';
GRANT ALL PRIVILEGES ON autoflow.* TO 'autoflow'@'%';

FLUSH PRIVILEGES;

-- 확인
SELECT User, Host FROM mysql.user WHERE User = 'autoflow';
SHOW DATABASES LIKE 'autoflow';
