/linux:linux-mysql-mariadbfrom linux
Installs, secures, tunes, backs up, restores, and diagnoses MySQL or MariaDB on Debian/Ubuntu and RHEL-family hosts. Covers InnoDB, logical dumps, binlogs, and point-in-time recovery.
Ships in linux. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Two-family skill for two distinct server products. Do not assume their package,
configuration, service, or SQL behavior is interchangeable; verify the target
product and release. The split that matters most is the config drop-in
directory and the service/unit name. The body below uses the RHEL-family
paths (grounded in RHEL 9 Recipes 37 & 39); Debian/Ubuntu paths are in the
matrix and in
references/install-and-secure.md.
| Concept | Debian/Ubuntu | RHEL family (Fedora, RHEL, CentOS Stream, Rocky, Alma, Oracle) |
|---|---|---|
| Install MariaDB | apt install mariadb-server; Debian's default-mysql-server resolves to MariaDB in the inspected Debian 13 package index | dnf install mariadb-server |
| Install Oracle MySQL | Use Oracle's official APT repository only when it supports the target Debian/Ubuntu release; do not treat default-mysql-server as Oracle MySQL | dnf install mysql-server only where the target RHEL-family release provides the supported MySQL stream/package |
| Service (Oracle MySQL) | mysql when installed from a supported Oracle MySQL package | mysqld when provided by the selected MySQL package |
| Service (MariaDB) | mariadb | mariadb |
| Main config | Product-specific includes under /etc/mysql/; inspect the installed server's include chain | Product-specific includes under /etc/my.cnf.d/; inspect the installed server's include chain |
| Tuning drop-in | Use the include directory for the installed product and release; verify before editing | /etc/my.cnf.d/zz-tuning.cnf when included by the installed product |
| Data dir | /var/lib/mysql | /var/lib/mysql |
| Client config (root) | /root/.my.cnf or mariadb/mysql socket auth | /root/.my.cnf or socket auth |
| Secure script | mysql_secure_installation | mysql_secure_installation |
| Logs | journalctl -u mysql / mariadb | journalctl -u mysqld / mariadb |
The CLI command names depend on the selected product and package. Verify the
installed client before relying on mysql, mysqldump, or mysqlbinlog.
On RHEL 9, MySQL and MariaDB conflict — you cannot install both (RHEL 9
Recipe 39). Use the svc_name/pkg_install helpers from common.sh in
sk-* scripts so one script runs on both families; see
docs/multi-distro/plan.md.
[GROUNDING-GAP: DB tuning/PITR — InnoDB tuning, binary logging and point-in-time recovery are NOT in the corpus; grounded on official MySQL 8 / MariaDB Server docs; deepen with High Performance MySQL 4e (O'Reilly). Install/secure is grounded in RHEL 9 Recipes 37 & 39.]
linux-webstack.linux-inmemory-stores.linux-rsync-sync or linux-archive-integrity.| Artefact | Required? | Source | If absent |
|---|---|---|---|
| Engine/version, distro, topology, and service objective | yes | Inventory and database owner | Stop before installation, upgrade, or config changes. |
| Workload measurements and host memory budget | tuning only | Metrics and capacity plan | Limit work to read-only diagnostics; do not invent tuning values. |
| RPO/RTO, destination, retention, and encryption policy | backup/PITR | Recovery policy | Do not claim recoverability; provide a qualified design only. |
| Maintenance window and rollback | mutation | Approved change record | Do not restart or modify production. |
Diagnostics default to read-only database and host access. Package changes, SQL writes, config edits, restarts, backup rotation, restores, and binlog replay require explicit authority. Credentials must come from the approved secret provider and never appear in commands or evidence.
Without database access, return version-specific commands and label values unverified. Without workload evidence, do not prescribe numeric tuning. Without an isolated restore target, mark recovery not proven.
| Choice | Action | Failure or risk avoided |
|---|---|---|
| MySQL versus MariaDB | Preserve the installed engine unless migration evidence authorises a change; never install conflicting RHEL packages together. | Accidental fork migration or package conflict. |
| Logical backup | Use --single-transaction for InnoDB and include required routines, events, triggers, and grants. | Inconsistent or incomplete restore. |
| PITR | Enable, retain, and monitor binlogs when RPO is shorter than the dump interval. | Recovery gap between dumps. |
| Tuning | Change one justified drop-in at a time and load-test it. | Memory exhaustion and untraceable regressions. |
For the supported sk-mysql-backup workflow, private staging, encryption,
retention behavior, and a repeatable second-instance restore check, follow
references/backup-and-restore.md.
--single-transaction for InnoDB dumps (consistent, non-locking).Changing the database fork implicitly. Fix: preserve the installed engine unless migration is explicitly approved.
Tuning from host RAM alone. Fix: combine workload and per-connection evidence with OS headroom.
Editing vendor configuration. Fix: use one owned ordered drop-in and record rollback.
Treating dump completion as recovery proof. Fix: restore to isolation and reconcile objects/data.
Passing database passwords on the command line. Fix: use socket auth or a protected option file.
Leaving anonymous users, the test database, or remote root login. Correction: remove them before exposure and verify grants.
Sizing innodb_buffer_pool_size to all RAM. Correction: use workload evidence and leave OS/connection headroom.
Using dumps alone for a shorter RPO. Correction: retain tested binlogs and coordinates.
Editing vendor my.cnf. Correction: use an owned, ordered drop-in with a clean rollback.
Treating a successful dump as recovery proof. Correction: restore to scratch and reconcile schema and data.
Passing passwords on the command line. Correction: use socket auth or a protected option file from the secret workflow.
| Artefact | Consumer | Acceptance condition |
|---|---|---|
| Database change record | DBA/operator | Names engine/version, drop-in, before/after values, validation, restart, and rollback. |
| Backup set and manifest | Recovery operator | Dump is checksummed, encrypted as required, retained at the approved destination, and includes required objects. |
| Restore/PITR report | Service owner | A second isolated instance restore succeeds and the declared recovery point is demonstrated or marked unproven. |
| Artefact | Acceptance |
|---|---|
| Database recovery evidence | Contains redacted config/version, backup checksum, binlog coordinates, restore logs, reconciliation, and health result. |
Capture redacted variables/config, server version, backup checksum and manifest, binlog coordinates/retention, restore logs, reconciliation counts, and final health checks.
For a MariaDB service with a 15-minute RPO, take a consistent dump, record its binlog position, restore it to scratch, and replay to a chosen timestamp. Do not claim PITR until replay and reconciliation pass.
# RHEL family (App Stream) — MySQL 8 (Recipe 37) or MariaDB 10.x (Recipe 39)
sudo dnf install mysql-server # MySQL
sudo systemctl enable --now mysqld
# — or —
sudo dnf install mariadb-server # MariaDB (cannot coexist with mysql-server)
sudo systemctl enable --now mariadb
# Debian/Ubuntu
sudo apt install mariadb-server # or: mysql-server
sudo systemctl enable --now mariadb # unit is 'mysql' for mysql-server
# Both families — harden before exposing (sets root pw, drops anon users,
# test DB, and remote root login):
sudo mysql_secure_installation
Full per-distro detail, socket vs password auth, and creating an app user with
least privilege: references/install-and-secure.md.
Never edit the packaged my.cnf. Drop a numbered file in the include dir so it
sorts last and wins:
# RHEL family
sudo install -m 0644 /dev/null /etc/my.cnf.d/zz-tuning.cnf
# Debian/Ubuntu
sudo install -m 0644 /dev/null /etc/mysql/mysql.conf.d/zz-tuning.cnf
[mysqld]
# ~50-70% of RAM on a dedicated DB host (the single most impactful knob).
innodb_buffer_pool_size = 4G
# Redo log size. Larger = fewer flushes, faster writes, slower crash recovery.
# MySQL 8.0.30+: prefer innodb_redo_log_capacity instead of innodb_log_file_size.
innodb_log_file_size = 512M
# One file per table — easier reclaim of space, per-table operations.
innodb_file_per_table = ON
# Durability: 1 = ACID (flush each commit). 2 trades crash-safety for speed.
innodb_flush_log_at_trx_commit = 1
# Connection ceiling. Each connection costs memory — size to the app's real
# concurrency, not an arbitrary large number.
max_connections = 200
Apply, then verify live values:
sudo systemctl restart mysqld # or 'mariadb' / 'mysql'
mysql -e "SHOW VARIABLES LIKE 'innodb_buffer_pool_size';"
mysql -e "SHOW VARIABLES LIKE 'max_connections';"
Rationale, sizing math, redo-log capacity changes across versions, and
mysqltuner-style review: references/tuning-innodb.md.
# Consistent, non-locking InnoDB dump of one database:
mysqldump --single-transaction --routines --triggers --events mydb > mydb.sql
# All databases (combined), with binlog coordinate for PITR (see below):
mysqldump --all-databases --single-transaction --routines --triggers --events \
--source-data=2 > all.sql # --master-data=2 on older versions
# Restore:
mysql mydb < mydb.sql
A nightly dump only restores to the dump instant. To recover to any point, combine a base dump with the binary logs written since:
[mysqld]
log_bin = /var/lib/mysql/binlog # MariaDB: log_bin = mariadb-bin
server_id = 1
binlog_format = ROW
expire_logs_days = 7 # MySQL 8: binlog_expire_logs_seconds
# 1. Base dump records the starting binlog coordinate:
mysqldump --all-databases --single-transaction --source-data=2 > base.sql
# 2. Disaster strikes. Restore the base dump:
mysql < base.sql
# 3. Replay binlogs from the recorded position up to just before the bad event:
mysqlbinlog --stop-datetime="2026-06-15 14:29:59" \
/var/lib/mysql/binlog.000007 | mysql
Full PITR procedure, finding the right binlog/position, --start-position,
GTID notes, and MariaDB differences:
references/binlog-and-pitr.md.
mysqladmin status # uptime, threads, qps
mysql -e "SHOW GLOBAL STATUS LIKE 'Threads_connected';"
mysql -e "SHOW ENGINE INNODB STATUS\G" | head -40 # locks, buffer pool, I/O
mysql -e "SHOW PROCESSLIST;" # live queries
This skill installs the following scripts to /usr/local/bin/. To install:
sudo install-skills-bin linux-mysql-mariadb
| Script | Source | Core? | Purpose |
|---|---|---|---|
| sk-mysql-health | scripts/sk-mysql-health.sh | yes | Read-only health check: connectivity, uptime/qps, threads vs max_connections, InnoDB buffer-pool hit ratio, binary-logging state, slow-query count. Both families. PASS/WARN/FAIL summary. |
| sk-mysql-backup | scripts/sk-mysql-backup.sh | no | Dump all databases (--single-transaction, per-db + combined), compress, GPG-encrypt, upload via rclone, rotate local + remote copies. Interactive by default; --yes for cron. Runs on both families. |
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub peterbamuhigire/linux-skills --plugin linux45 skills in this plugin
/cisco-ios-patternsUse when reading or reviewing Cisco IOS/IOS-XE configuration, selecting read-only show commands, or planning and verifying bounded router or switch configuration work. Not for Linux host networking, bulk SSH automation, or config preflight parsing; route those to linux-network-admin, netmiko-ssh-automation, or network-config-validation./linux-access-controlUse when creating, revoking, or auditing Linux users, groups, SSH keys, sudo/wheel access, PAM settings, SELinux user mappings, or file permissions. Use linux-secrets for credential material and linux-server-hardening for broader host policy./linux-archive-integrityUse when creating, signing, encrypting, listing, comparing, or restoring metadata-preserving tar archives on Debian/Ubuntu or RHEL-family hosts. Covers ACLs, xattrs, incrementals, and verification; use linux-rsync-sync for file-tree mirrors./linux-auditd-rulesUse when inspecting, designing, testing, persisting, or querying auditd rules for forensic attribution on Debian/Ubuntu or RHEL-family hosts. Covers watches, syscalls, loss, and immutable mode; use linux-file-integrity for drift and linux-benchmark-scanning for scoring./linux-bash-scriptingUse when writing or reviewing portable sk-* Bash scripts for this engine, including common.sh primitives, flags, preview mode, and safety gates; use linux-repo-sync for Git-update behaviour and not for one-off commands./linux-benchmark-scanningUse when running read-only OpenSCAP or Lynis scans, selecting distro-matched profiles, interpreting failures, or drafting remediation on Debian/Ubuntu or RHEL-family hosts. Use linux-auditd-rules for attribution and linux-file-integrity for AIDE drift.Other plugins' skills for the same job