MySQL Admin Scripts
Automated MySQL administration: replication setup, backup scripts, user management, and health monitoring queries.
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 26 files
📖 Documentation Preview README excerpt
MySQL Admin Scripts
A practical toolkit for the day-to-day administration of MySQL and MariaDB:
backups, replication, user/grant audits, slow-query analysis, InnoDB health, and
tuning references. Everything is real, runnable, and commented — the SQL you'd
paste into a session during an incident and the shell scripts you'd drop into
cron, not abstractions to learn.
Built for MySQL 8.0 and MariaDB 10.3+, with version differences (e.g.
SHOW REPLICA STATUS vs SHOW SLAVE STATUS) called out inline. Scripts use only
the standard mysql/mysqldump clients plus optional Percona XtraBackup.
What's included
mysql-admin-scripts/
├── README.md
├── LICENSE
├── sql/ # diagnostics to run in a session
│ ├── 01_user_grant_audit.sql Over-privileged & passwordless accounts
│ ├── 02_slow_query_analysis.sql Statement digests, missing-index signals
│ ├── 03_innodb_status.sql Buffer pool hit ratio, dirty pages, locks
│ ├── 04_table_and_index_sizes.sql Biggest tables, fragmentation, dead indexes
│ ├── 05_replication_status.sql GTID, replica lag, thread state
│ └── 06_processlist_and_locks.sql Live queries, long txns, blocking trees
├── scripts/ # bash automation (set -euo pipefail)
│ ├── mysql_backup.sh Consistent mysqldump + gzip + rotation
│ ├── mysql_restore.sh Safe restore with integrity check
│ ├── xtrabackup_full.sh Percona XtraBackup hot backup + prepare
│ ├── check_replication.sh Cron/monitor replica health check
│ └── create_app_user.sh Least-privilege scoped app user
├── config/
│ └── my.cnf.reference Annotated 8.0 tuning reference
├── docs/
│ ├── BACKUP-RESTORE.md Logical vs physical, PITR, restore drills
│ ├── REPLICATION-SETUP.md End-to-end GTID replication
│ ├── INNODB-TUNING.md Buffer pool, redo log, durability
│ ├── SLOW-QUERY-ANALYSIS.md performance_schema + slow log workflow
│ └── USER-GRANT-MANAGEMENT.md Least-privilege model & roles
└── examples/
└── sample_schema.sql Synthetic schema + data to test against
Prerequisites
- MySQL 8.0 or MariaDB 10.3+ (most queries also work on MySQL 5.7;
version-specific notes are inline).
- The standard
mysqlandmysqldumpclients. - For
scripts/xtrabackup_full.sh: Percona XtraBackup (8.0 for MySQL 8.0,
2.4 for 5.7).
performance_schemaenabled (default in 8.0) forsql/02,03,06.- Credentials are never stored in this kit. Every script reads them from a
MySQL defaults-extra-file ([client] section, chmod 600) so passwords
never hit the command line, ps, or your shell history.
A defaults file looks like:
... continues with setup instructions, usage examples, and more.