// MySQL Administrator
MySQL Administrator
คู่มือสำหรับ DBA — Backup & Recovery, Replication, User Management, Monitoring และ High Availability
Backup & Recovery
กลยุทธ์ Backup ที่เหมาะสม — mysqldump, MySQL Enterprise Backup, Binary Log และ Point-in-Time Recovery
Replication
ตั้งค่า Master-Slave และ Group Replication เพื่อ High Availability และ Read Scaling
User Management
สร้างและจัดการ MySQL Users ด้วย Principle of Least Privilege
Monitoring
ตรวจสอบสุขภาพของ Server ด้วย Performance Schema, sys Schema และ MySQL Enterprise Monitor
Performance
Tune Configuration, Analyze Slow Queries และ Optimize Index เพื่อประสิทธิภาพสูงสุด
Security
Harden MySQL Server, จัดการ Permissions และตั้งค่า SSL/TLS
// Essential Commands
คำสั่งสำคัญสำหรับ DBA
💾 Backup & Restore
# Full backup with mysqldump
$ mysqldump -u root -p \
--all-databases \
--single-transaction \
--routines --triggers \
> backup_$(date +%Y%m%d).sql
# Restore
$ mysql -u root -p < backup.sql
# Backup single database
$ mysqldump -u root -p mydb \
> mydb_backup.sql
📊 Server Monitoring
-- Check running processes
SHOW PROCESSLIST;
-- Check InnoDB status
SHOW ENGINE INNODB STATUS\G
-- Check table sizes
SELECT table_name,
ROUND(data_length/1024/1024,2) AS data_mb,
ROUND(index_length/1024/1024,2) AS idx_mb
FROM information_schema.tables
WHERE table_schema = 'mydb'
ORDER BY data_length DESC;
👤 User Management
-- Create user
CREATE USER 'dba'@'localhost'
IDENTIFIED BY 'SecurePass!';
-- Grant privileges
GRANT ALL PRIVILEGES ON mydb.*
TO 'dba'@'localhost';
-- Show grants
SHOW GRANTS FOR 'dba'@'localhost';
-- Revoke
REVOKE DELETE ON mydb.*
FROM 'dba'@'localhost';
🔄 Replication Setup
# Master: my.cnf
[mysqld]
server-id = 1
log_bin = /var/log/mysql/mysql-bin
binlog_do_db = mydb
# Slave: my.cnf
[mysqld]
server-id = 2
relay-log = /var/log/mysql/relay-bin
-- On Slave:
CHANGE MASTER TO
MASTER_HOST='master_ip',
MASTER_USER='repl',
MASTER_PASSWORD='pass';
START SLAVE;
ต้องการ DBA Support?
เราให้บริการ On-Call DBA Support 24x7 ทั้ง Remote และ On-site