-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-database.sql
More file actions
32 lines (24 loc) · 944 Bytes
/
setup-database.sql
File metadata and controls
32 lines (24 loc) · 944 Bytes
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
26
27
28
29
30
31
32
-- ========================================
-- MariaDB Setup Script
-- Customer Management System
-- ========================================
-- Drop existing database if exists (CAREFUL: This deletes all data!)
-- DROP DATABASE IF EXISTS customer_management_db;
-- Create database with UTF8 support
CREATE DATABASE IF NOT EXISTS customer_management_db
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
-- Create user for application
DROP USER IF EXISTS 'cms_user'@'localhost';
CREATE USER 'cms_user'@'localhost' IDENTIFIED BY 'cms_pass';
-- Grant all privileges on the database
GRANT ALL PRIVILEGES ON customer_management_db.* TO 'cms_user'@'localhost';
FLUSH PRIVILEGES;
-- Switch to database
USE customer_management_db;
-- Show current database
SELECT DATABASE() as 'Current Database';
-- Verify user permissions
SHOW GRANTS FOR 'cms_user'@'localhost';
-- Show message
SELECT 'Database and user created successfully!' as 'Status';