-- MySQL Database Setup for Wildanet Quiz
-- Run this with: sudo mysql < setup-database.sql

-- Create database if not exists
CREATE DATABASE IF NOT EXISTS quiz_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- Create a dedicated user for the quiz application
CREATE USER IF NOT EXISTS 'quiz_user'@'localhost' IDENTIFIED BY 'Quiz2024!Secure';

-- Grant all privileges on quiz_db to quiz_user
GRANT ALL PRIVILEGES ON quiz_db.* TO 'quiz_user'@'localhost';

-- Flush privileges to apply changes
FLUSH PRIVILEGES;

-- Use the quiz_db database
USE quiz_db;

-- Show current user
SELECT USER(), DATABASE();
