← Back to all products

MySQL Admin Scripts

$29

Automated MySQL administration: replication setup, backup scripts, user management, and health monitoring queries.

28 files
ShellMarkdownSQLJSON

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 28 files

mysql-admin-scripts/ ├── LICENSE ├── README.md ├── config/ │ └── my.cnf.reference ├── docs/ │ ├── BACKUP-RESTORE.md │ ├── INNODB-TUNING.md │ ├── REPLICATION-SETUP.md │ ├── SLOW-QUERY-ANALYSIS.md │ └── USER-GRANT-MANAGEMENT.md ├── examples/ │ └── sample_schema.sql ├── free-sample.zip ├── guide/ │ ├── 01_what-s-included.md │ ├── 02_quick-start-5-minutes.md │ ├── 03_safety-notes.md │ └── 04_license.md ├── index.html ├── interactive.html ├── scripts/ │ ├── check_replication.sh │ ├── create_app_user.sh │ ├── mysql_backup.sh │ ├── mysql_restore.sh │ └── xtrabackup_full.sh └── sql/ ├── 01_user_grant_audit.sql ├── 02_slow_query_analysis.sql ├── 03_innodb_status.sql ├── 04_table_and_index_sizes.sql ├── 05_replication_status.sql └── 06_processlist_and_locks.sql

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 mysql and mysqldump clients.
  • For scripts/xtrabackup_full.sh: Percona XtraBackup (8.0 for MySQL 8.0,

2.4 for 5.7).

  • performance_schema enabled (default in 8.0) for sql/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.

Code Sample .sql preview

examples/sample_schema.sql -- ============================================================================= -- examples/sample_schema.sql -- A small realistic schema + seed data for trying the diagnostics safely. -- ----------------------------------------------------------------------------- -- Load into a scratch database, then run the sql/ diagnostics against it: -- -- mysql -u root -p -e "CREATE DATABASE IF NOT EXISTS adminkit_demo;" -- mysql -u root -p adminkit_demo < examples/sample_schema.sql -- -- The data is synthetic, contains no real people, and is intentionally small so -- it loads quickly. A recursive CTE generates the rows (MySQL 8.0 / MariaDB -- 10.2+). One table (orders.customer_id) is intentionally left without a -- secondary index so sql/02 and EXPLAIN have something to find. -- -- Tested on: MySQL 8.0, MariaDB 10.5+. -- ============================================================================= -- Raise the recursion depth so the generator CTEs can produce enough rows. SET SESSION cte_max_recursion_depth = 1000000; DROP TABLE IF EXISTS order_items; DROP TABLE IF EXISTS orders; DROP TABLE IF EXISTS products; DROP TABLE IF EXISTS customers; -- ----------------------------------------------------------------------------- -- Tables (all InnoDB, utf8mb4) -- ----------------------------------------------------------------------------- CREATE TABLE customers ( id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, email VARCHAR(255) NOT NULL, full_name VARCHAR(120) NOT NULL, country CHAR(2) NOT NULL, created_at DATETIME NOT NULL, is_active TINYINT(1) NOT NULL DEFAULT 1, UNIQUE KEY uq_customers_email (email) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE TABLE products ( id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, sku VARCHAR(32) NOT NULL, name VARCHAR(160) NOT NULL, category VARCHAR(32) NOT NULL, price_cents INT NOT NULL, in_stock TINYINT(1) NOT NULL DEFAULT 1, UNIQUE KEY uq_products_sku (sku), KEY idx_products_category (category) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- NOTE: customer_id intentionally has NO secondary index yet (see the examples). # ... 101 more lines ...