[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6F98H46M0M1VPFD0GGPXYAD":3,"skill-same:01M6F98H46M0M1VPFD0GGPXYAD":73},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":28,"commitSha":53,"skillDirectory":54,"forksCount":55,"repositoryHtmlUrl":56,"repositoryHomepageUrl":6,"ownerHtmlUrl":57,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":58,"install":59,"resources":72},"01M6F98H46M0M1VPFD0GGPXYAD","mysql",null,"Administer MySQL\u002FMariaDB databases. Configure replication and optimize performance. Use when managing MySQL deployments.","boisenoise\u002Fskills-collections","boisenoise","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F193180?v=4","01M6CDBDQK6BDN55ZMA6B6PKBM","01M6CDBDVSJ3JPTBYN26FZ7TZK",12,"MIT","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-mysql\u002FSKILL.md",[],[5,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"community","2026","when","relevant","replication","scripts","critical","os","platform","optimize","main","security","deployments","databases","agent-skills","only","configure","access","devops-security","license","performance","2026-11-10 10:12:30",false,"---\nname: mysql\ndescription: Administer MySQL\u002FMariaDB databases. Configure replication and optimize\n  performance. Use when managing MySQL deployments.\ncategory: devops\nrisk: critical\nsource: https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\nsource_repo: BagelHole\u002FDevOps-Security-Agent-Skills\nsource_type: community\ndate_added: '2026-09-20'\nlicense: MIT\nlicense_source: https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\u002Fblob\u002Fmain\u002FLICENSE\ncompatibility: Requires the relevant OS\u002Fplatform tooling and privileged access where\n  noted. Docs-only; helper scripts and templates not bundled.\nmetadata:\n  author: devops-skills\n  version: '1.0'\n---\n\n# MySQL \u002F MariaDB\n\nAdminister, optimize, and secure MySQL and MariaDB databases in development and production environments.\n\n## When to Use\n\n- You need a mature, widely supported relational database.\n- Your stack depends on MySQL-specific features or compatibility (WordPress, Magento, many PHP frameworks).\n- You are setting up source-replica replication for read scaling.\n- You want to tune InnoDB for high-throughput transactional workloads.\n\n## Prerequisites\n\n- Linux server (Debian\u002FUbuntu or RHEL-based) or Docker.\n- Root or sudo access for package installation.\n- Familiarity with SQL fundamentals.\n\n## Version and recovery boundaries\n\nMySQL and MariaDB are not interchangeable: select exact server\u002Ftool versions and supported replication syntax before adapting these examples. Tuning values are workload examples; some InnoDB options are removed or replaced in newer versions. Real credentials belong in protected option files\u002Fsecret providers, not command arguments, Compose source or history. Replace sample credentials and bind only the required private interfaces. XtraBackup must match the server version; --move-back consumes the backup files, so preserve an independent copy. --single-transaction consistency depends on transactional tables and no concurrent DDL. Do not skip replication errors or kill blocking transactions without diagnosing consistency\u002Frollback consequences. REPAIR TABLE does not repair InnoDB. A zero lag counter alone does not prove a healthy consistent replica; validate initialization from a matching snapshot\u002Flog position and use encrypted replication. Backup pipelines must propagate failures (pipefail) and be restore-tested.\n\n## Installation and Setup\n\n```bash\n# Debian \u002F Ubuntu — MySQL 8\nsudo apt update\nsudo apt install -y mysql-server\n\n# RHEL \u002F Amazon Linux\nsudo dnf install -y mysql-server\nsudo systemctl enable --now mysqld\n\n# Run the secure installation wizard\nsudo mysql_secure_installation\n# Prompts: set root password, remove anonymous users, disable remote root, remove test db\n\n# Verify\nmysql --version\nsudo systemctl status mysql\n```\n\n## Initial User and Database Setup\n\n```bash\nsudo mysql -u root -p\n```\n\n```sql\n-- Create a database\nCREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;\n\n-- Create an application user with strong auth\nCREATE USER 'myapp'@'%' IDENTIFIED BY 'strong_password_here';\nGRANT SELECT, INSERT, UPDATE, DELETE ON mydb.* TO 'myapp'@'%';\nFLUSH PRIVILEGES;\n\n-- Verify\nSHOW GRANTS FOR 'myapp'@'%';\n```\n\n## mysql CLI Reference\n\n```bash\n# Connect\nmysql -u myapp -p -h 127.0.0.1 mydb\n\n# Execute a single statement\nmysql -u myapp -p -e \"SELECT COUNT(*) FROM orders;\" mydb\n\n# Import a SQL file\nmysql -u myapp -p mydb \u003C schema.sql\n\n# Export query results to CSV\nmysql -u myapp -p -e \"SELECT * FROM users\" mydb \\\n  > users.tsv  # tabular output, not escaped CSV\n```\n\n```\n-- Inside the mysql shell\nSHOW DATABASES;\nUSE mydb;\nSHOW TABLES;\nDESCRIBE users;\nSHOW CREATE TABLE users\\G\nSHOW PROCESSLIST;\nSHOW ENGINE INNODB STATUS\\G\n```\n\n## Configuration Tuning\n\nEdit `\u002Fetc\u002Fmysql\u002Fmysql.conf.d\u002Fmysqld.cnf` (or `\u002Fetc\u002Fmy.cnf` on RHEL).\n\n```ini\n[mysqld]\n# -- Networking --\nbind-address           = 127.0.0.1\nmax_connections        = 300\nwait_timeout           = 600\ninteractive_timeout    = 600\n\n# -- InnoDB (most impactful settings) --\ninnodb_buffer_pool_size   = 4G          # ~70% of RAM on a dedicated server\ninnodb_buffer_pool_instances = 4        # 1 per GB of pool (up to 64)\ninnodb_log_file_size      = 1G\ninnodb_flush_log_at_trx_commit = 1      # 1 = ACID; 2 = faster, slight risk\ninnodb_flush_method       = O_DIRECT    # avoids double buffering on Linux\ninnodb_io_capacity        = 2000        # raise for SSD\ninnodb_io_capacity_max    = 4000\n\n# -- Query cache (disabled in MySQL 8, use ProxySQL or app cache) --\n# query_cache_type = 0\n\n# -- Logging --\nslow_query_log         = 1\nslow_query_log_file    = \u002Fvar\u002Flog\u002Fmysql\u002Fslow.log\nlong_query_time        = 1\nlog_error              = \u002Fvar\u002Flog\u002Fmysql\u002Ferror.log\n\n# -- Binary log (required for replication) --\nserver-id              = 1\nlog_bin                = \u002Fvar\u002Flog\u002Fmysql\u002Fmysql-bin\nbinlog_expire_logs_seconds = 604800     # 7 days\nsync_binlog            = 1\n\n# -- Character set --\ncharacter-set-server   = utf8mb4\ncollation-server       = utf8mb4_unicode_ci\n```\n\n```bash\n# Apply changes\nsudo systemctl restart mysql\n\n# Verify a setting at runtime\nmysql -u root -p -e \"SHOW VARIABLES LIKE 'innodb_buffer_pool_size';\"\n```\n\n## Backup and Restore\n\n### Logical Backups with mysqldump\n\n```bash\n# Single database\nmysqldump -u root -p --single-transaction --routines --triggers \\\n  mydb > \u002Fbackups\u002Fmydb_$(date +%F).sql\n\n# All databases\nmysqldump -u root -p --all-databases --single-transaction \\\n  > \u002Fbackups\u002Fall_$(date +%F).sql\n\n# Compressed backup\nmysqldump -u root -p --single-transaction mydb \\\n  | gzip > \u002Fbackups\u002Fmydb_$(date +%F).sql.gz\n\n# Restore\nmysql -u root -p mydb \u003C \u002Fbackups\u002Fmydb_2025-01-15.sql\n\n# Restore compressed\ngunzip \u003C \u002Fbackups\u002Fmydb_2025-01-15.sql.gz | mysql -u root -p mydb\n```\n\n### Physical Backups with Percona XtraBackup\n\n```bash\n# Install\nsudo apt install -y percona-xtrabackup-80\n\n# Full backup\nxtrabackup --backup --user=root --password=secret \\\n  --target-dir=\u002Fbackups\u002Ffull_$(date +%F)\n\n# Prepare the backup (apply redo logs)\nxtrabackup --prepare --target-dir=\u002Fbackups\u002Ffull_2025-01-15\n\n# Restore (stop MySQL first)\nsudo systemctl stop mysql\nls \u002Fvar\u002Flib\u002Fmysql\u002F*  # verify this is the correct data dir first\n# Preserve the stopped data directory in a separately verified recovery location.\n# Do not delete it; prepare an empty destination only after a tested restore plan.\nxtrabackup --move-back --target-dir=\u002Fbackups\u002Ffull_2025-01-15\nsudo chown -R mysql:mysql \u002Fvar\u002Flib\u002Fmysql\nsudo systemctl start mysql\n```\n\n### Incremental Backup with XtraBackup\n\n```bash\n# Incremental based on the full backup\nxtrabackup --backup --user=root --password=secret \\\n  --target-dir=\u002Fbackups\u002Finc_$(date +%F) \\\n  --incremental-basedir=\u002Fbackups\u002Ffull_2025-01-15\n\n# Prepare: apply full, then incremental\nxtrabackup --prepare --apply-log-only --target-dir=\u002Fbackups\u002Ffull_2025-01-15\nxtrabackup --prepare --target-dir=\u002Fbackups\u002Ffull_2025-01-15 \\\n  --incremental-dir=\u002Fbackups\u002Finc_2025-01-16\n```\n\n## Source-Replica Replication\n\n### Source (Primary)\n\n```ini\n# \u002Fetc\u002Fmysql\u002Fmysql.conf.d\u002Fmysqld.cnf\n[mysqld]\nserver-id       = 1\nlog_bin         = \u002Fvar\u002Flog\u002Fmysql\u002Fmysql-bin\nbinlog_format   = ROW\n```\n\n```sql\n-- Create replication user\nCREATE USER 'replicator'@'10.0.0.%' IDENTIFIED BY 'repl_secret';\nGRANT REPLICATION SLAVE ON *.* TO 'replicator'@'10.0.0.%';\nFLUSH PRIVILEGES;\n\n-- Get current binary log position\nSHOW MASTER STATUS\\G\n```\n\n### Replica\n\n```ini\n# \u002Fetc\u002Fmysql\u002Fmysql.conf.d\u002Fmysqld.cnf\n[mysqld]\nserver-id  = 2\nrelay_log  = \u002Fvar\u002Flog\u002Fmysql\u002Frelay-bin\nread_only  = ON\n```\n\n```sql\n-- Point replica to source (use SHOW MASTER STATUS values)\nCHANGE REPLICATION SOURCE TO\n  SOURCE_HOST     = '10.0.0.1',\n  SOURCE_USER     = 'replicator',\n  SOURCE_PASSWORD = '...', -- supply the replication secret securely\n  SOURCE_LOG_FILE = 'mysql-bin.000003',\n  SOURCE_LOG_POS  = 154;\n\nSTART REPLICA;\n\n-- Verify\nSHOW REPLICA STATUS\\G\n-- Check: Replica_IO_Running = Yes, Replica_SQL_Running = Yes, Seconds_Behind_Source = 0\n```\n\n## Monitoring Queries\n\n```sql\n-- Connection statistics\nSHOW STATUS LIKE 'Threads_connected';\nSHOW STATUS LIKE 'Max_used_connections';\n\n-- InnoDB buffer pool hit ratio (should be > 99%)\nSELECT\n  ROUND(100 - (\n    (SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME = 'Innodb_buffer_pool_reads') \u002F\n    (SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME = 'Innodb_buffer_pool_read_requests')\n  ) * 100, 2) AS buffer_pool_hit_pct;\n\n-- Top 10 slow queries (requires performance_schema)\nSELECT DIGEST_TEXT, COUNT_STAR, AVG_TIMER_WAIT \u002F 1e12 AS avg_sec\nFROM performance_schema.events_statements_summary_by_digest\nORDER BY AVG_TIMER_WAIT DESC\nLIMIT 10;\n\n-- Table sizes\nSELECT table_name,\n       ROUND(data_length \u002F 1024 \u002F 1024, 2) AS data_mb,\n       ROUND(index_length \u002F 1024 \u002F 1024, 2) AS index_mb,\n       table_rows\nFROM information_schema.tables\nWHERE table_schema = 'mydb'\nORDER BY data_length DESC;\n\n-- Check replication lag\nSHOW REPLICA STATUS\\G\n-- Look at Seconds_Behind_Source\n```\n\n## Docker Compose Setup\n\n```yaml\n# docker-compose.yml\nversion: \"3.9\"\n\nservices:\n  mysql:\n    image: mysql:8.0\n    restart: unless-stopped\n    ports:\n      - \"127.0.0.1:3306:3306\"\n    environment:\n      MYSQL_ROOT_PASSWORD: rootpass\n      MYSQL_DATABASE: mydb\n      MYSQL_USER: myapp\n      MYSQL_PASSWORD: secret\n    volumes:\n      - mysql_data:\u002Fvar\u002Flib\u002Fmysql\n      - .\u002Finit.sql:\u002Fdocker-entrypoint-initdb.d\u002Finit.sql\n    command: >\n      --innodb-buffer-pool-size=512M\n      --max-connections=200\n      --slow-query-log=ON\n      --long-query-time=1\n      --character-set-server=utf8mb4\n      --collation-server=utf8mb4_unicode_ci\n    healthcheck:\n      test: [\"CMD\", \"mysqladmin\", \"ping\", \"-h\", \"localhost\", \"-u\", \"root\", \"-prootpass\"]\n      interval: 10s\n      timeout: 5s\n      retries: 5\n\n  phpmyadmin:\n    image: phpmyadmin:latest\n    restart: unless-stopped\n    ports:\n      - \"127.0.0.1:8080:80\"\n    environment:\n      PMA_HOST: mysql\n      PMA_USER: root\n      PMA_PASSWORD: rootpass\n    depends_on:\n      mysql:\n        condition: service_healthy\n\nvolumes:\n  mysql_data:\n```\n\n```bash\ndocker compose up -d\nmysql -h 127.0.0.1 -u myapp -psecret mydb\n```\n\n## Maintenance Tasks\n\n```bash\n# Optimize a fragmented table (locks the table briefly)\nmysql -u root -p -e \"OPTIMIZE TABLE mydb.orders;\"\n\n# Analyze tables to update statistics\nmysql -u root -p -e \"ANALYZE TABLE mydb.orders;\"\n\n# Check and repair a table\nmysql -u root -p -e \"CHECK TABLE mydb.orders;\"\nmysql -u root -p -e \"REPAIR TABLE mydb.orders;\"\n\n# Rotate slow query log\nsudo mv \u002Fvar\u002Flog\u002Fmysql\u002Fslow.log \u002Fvar\u002Flog\u002Fmysql\u002Fslow.log.old\nmysqladmin -u root -p flush-logs\n```\n\n## Troubleshooting\n\n| Symptom | Likely Cause | Fix |\n|---|---|---|\n| `Too many connections` | Connection limit exceeded | Increase `max_connections`; use connection pooling (ProxySQL) |\n| Slow queries across the board | `innodb_buffer_pool_size` too small | Set to ~70% of available RAM and restart |\n| Replication stopped (`SQL_Running: No`) | Duplicate key or schema mismatch on replica | Check `SHOW REPLICA STATUS\\G` error; skip or fix the row |\n| `Table is full` | Disk space exhausted or table limit hit | Free disk space; check `innodb_data_file_path` autoextend |\n| `Lock wait timeout exceeded` | Long-running transaction holding row locks | Identify with `SHOW ENGINE INNODB STATUS`; kill the blocking query |\n| High IOPS \u002F disk usage | Redo log too small causing frequent flushes | Increase `innodb_log_file_size` (requires restart) |\n\n## Related Skills\n\n- postgresql (`postgresql-devsec`) - Alternative relational database\n- database-backups (`database-backups`) - Automated backup strategies\n- redis (`redis`) - Caching layer to reduce database load\n- planetscale (`planetscale`) - Managed MySQL-compatible with branching\n\n## Limitations\n\n- Infrastructure commands can disrupt services: confirm target host\u002Fscope and have backups\u002Fsnapshots before mutating state.\n- Docs-only import: upstream scripts and templates not bundled.\n\n","# MySQL \u002F MariaDB\n\nAdminister, optimize, and secure MySQL and MariaDB databases in development and production environments.\n\n## When to Use\n\n- You need a mature, widely supported relational database.\n- Your stack depends on MySQL-specific features or compatibility (WordPress, Magento, many PHP frameworks).\n- You are setting up source-replica replication for read scaling.\n- You want to tune InnoDB for high-throughput transactional workloads.\n\n## Prerequisites\n\n- Linux server (Debian\u002FUbuntu or RHEL-based) or Docker.\n- Root or sudo access for package installation.\n- Familiarity with SQL fundamentals.\n\n## Version and recovery boundaries\n\nMySQL and MariaDB are not interchangeable: select exact server\u002Ftool versions and supported replication syntax before adapting these examples. Tuning values are workload examples; some InnoDB options are removed or replaced in newer versions. Real credentials belong in protected option files\u002Fsecret providers, not command arguments, Compose source or history. Replace sample credentials and bind only the required private interfaces. XtraBackup must match the server version; --move-back consumes the backup files, so preserve an independent copy. --single-transaction consistency depends on transactional tables and no concurrent DDL. Do not skip replication errors or kill blocking transactions without diagnosing consistency\u002Frollback consequences. REPAIR TABLE does not repair InnoDB. A zero lag counter alone does not prove a healthy consistent replica; validate initialization from a matching snapshot\u002Flog position and use encrypted replication. Backup pipelines must propagate failures (pipefail) and be restore-tested.\n\n## Installation and Setup\n\n```bash\n# Debian \u002F Ubuntu — MySQL 8\nsudo apt update\nsudo apt install -y mysql-server\n\n# RHEL \u002F Amazon Linux\nsudo dnf install -y mysql-server\nsudo systemctl enable --now mysqld\n\n# Run the secure installation wizard\nsudo mysql_secure_installation\n# Prompts: set root password, remove anonymous users, disable remote root, remove test db\n\n# Verify\nmysql --version\nsudo systemctl status mysql\n```\n\n## Initial User and Database Setup\n\n```bash\nsudo mysql -u root -p\n```\n\n```sql\n-- Create a database\nCREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;\n\n-- Create an application user with strong auth\nCREATE USER 'myapp'@'%' IDENTIFIED BY 'strong_password_here';\nGRANT SELECT, INSERT, UPDATE, DELETE ON mydb.* TO 'myapp'@'%';\nFLUSH PRIVILEGES;\n\n-- Verify\nSHOW GRANTS FOR 'myapp'@'%';\n```\n\n## mysql CLI Reference\n\n```bash\n# Connect\nmysql -u myapp -p -h 127.0.0.1 mydb\n\n# Execute a single statement\nmysql -u myapp -p -e \"SELECT COUNT(*) FROM orders;\" mydb\n\n# Import a SQL file\nmysql -u myapp -p mydb \u003C schema.sql\n\n# Export query results to CSV\nmysql -u myapp -p -e \"SELECT * FROM users\" mydb \\\n  > users.tsv  # tabular output, not escaped CSV\n```\n\n```\n-- Inside the mysql shell\nSHOW DATABASES;\nUSE mydb;\nSHOW TABLES;\nDESCRIBE users;\nSHOW CREATE TABLE users\\G\nSHOW PROCESSLIST;\nSHOW ENGINE INNODB STATUS\\G\n```\n\n## Configuration Tuning\n\nEdit `\u002Fetc\u002Fmysql\u002Fmysql.conf.d\u002Fmysqld.cnf` (or `\u002Fetc\u002Fmy.cnf` on RHEL).\n\n```ini\n[mysqld]\n# -- Networking --\nbind-address           = 127.0.0.1\nmax_connections        = 300\nwait_timeout           = 600\ninteractive_timeout    = 600\n\n# -- InnoDB (most impactful settings) --\ninnodb_buffer_pool_size   = 4G          # ~70% of RAM on a dedicated server\ninnodb_buffer_pool_instances = 4        # 1 per GB of pool (up to 64)\ninnodb_log_file_size      = 1G\ninnodb_flush_log_at_trx_commit = 1      # 1 = ACID; 2 = faster, slight risk\ninnodb_flush_method       = O_DIRECT    # avoids double buffering on Linux\ninnodb_io_capacity        = 2000        # raise for SSD\ninnodb_io_capacity_max    = 4000\n\n# -- Query cache (disabled in MySQL 8, use ProxySQL or app cache) --\n# query_cache_type = 0\n\n# -- Logging --\nslow_query_log         = 1\nslow_query_log_file    = \u002Fvar\u002Flog\u002Fmysql\u002Fslow.log\nlong_query_time        = 1\nlog_error              = \u002Fvar\u002Flog\u002Fmysql\u002Ferror.log\n\n# -- Binary log (required for replication) --\nserver-id              = 1\nlog_bin                = \u002Fvar\u002Flog\u002Fmysql\u002Fmysql-bin\nbinlog_expire_logs_seconds = 604800     # 7 days\nsync_binlog            = 1\n\n# -- Character set --\ncharacter-set-server   = utf8mb4\ncollation-server       = utf8mb4_unicode_ci\n```\n\n```bash\n# Apply changes\nsudo systemctl restart mysql\n\n# Verify a setting at runtime\nmysql -u root -p -e \"SHOW VARIABLES LIKE 'innodb_buffer_pool_size';\"\n```\n\n## Backup and Restore\n\n### Logical Backups with mysqldump\n\n```bash\n# Single database\nmysqldump -u root -p --single-transaction --routines --triggers \\\n  mydb > \u002Fbackups\u002Fmydb_$(date +%F).sql\n\n# All databases\nmysqldump -u root -p --all-databases --single-transaction \\\n  > \u002Fbackups\u002Fall_$(date +%F).sql\n\n# Compressed backup\nmysqldump -u root -p --single-transaction mydb \\\n  | gzip > \u002Fbackups\u002Fmydb_$(date +%F).sql.gz\n\n# Restore\nmysql -u root -p mydb \u003C \u002Fbackups\u002Fmydb_2025-01-15.sql\n\n# Restore compressed\ngunzip \u003C \u002Fbackups\u002Fmydb_2025-01-15.sql.gz | mysql -u root -p mydb\n```\n\n### Physical Backups with Percona XtraBackup\n\n```bash\n# Install\nsudo apt install -y percona-xtrabackup-80\n\n# Full backup\nxtrabackup --backup --user=root --password=secret \\\n  --target-dir=\u002Fbackups\u002Ffull_$(date +%F)\n\n# Prepare the backup (apply redo logs)\nxtrabackup --prepare --target-dir=\u002Fbackups\u002Ffull_2025-01-15\n\n# Restore (stop MySQL first)\nsudo systemctl stop mysql\nls \u002Fvar\u002Flib\u002Fmysql\u002F*  # verify this is the correct data dir first\n# Preserve the stopped data directory in a separately verified recovery location.\n# Do not delete it; prepare an empty destination only after a tested restore plan.\nxtrabackup --move-back --target-dir=\u002Fbackups\u002Ffull_2025-01-15\nsudo chown -R mysql:mysql \u002Fvar\u002Flib\u002Fmysql\nsudo systemctl start mysql\n```\n\n### Incremental Backup with XtraBackup\n\n```bash\n# Incremental based on the full backup\nxtrabackup --backup --user=root --password=secret \\\n  --target-dir=\u002Fbackups\u002Finc_$(date +%F) \\\n  --incremental-basedir=\u002Fbackups\u002Ffull_2025-01-15\n\n# Prepare: apply full, then incremental\nxtrabackup --prepare --apply-log-only --target-dir=\u002Fbackups\u002Ffull_2025-01-15\nxtrabackup --prepare --target-dir=\u002Fbackups\u002Ffull_2025-01-15 \\\n  --incremental-dir=\u002Fbackups\u002Finc_2025-01-16\n```\n\n## Source-Replica Replication\n\n### Source (Primary)\n\n```ini\n# \u002Fetc\u002Fmysql\u002Fmysql.conf.d\u002Fmysqld.cnf\n[mysqld]\nserver-id       = 1\nlog_bin         = \u002Fvar\u002Flog\u002Fmysql\u002Fmysql-bin\nbinlog_format   = ROW\n```\n\n```sql\n-- Create replication user\nCREATE USER 'replicator'@'10.0.0.%' IDENTIFIED BY 'repl_secret';\nGRANT REPLICATION SLAVE ON *.* TO 'replicator'@'10.0.0.%';\nFLUSH PRIVILEGES;\n\n-- Get current binary log position\nSHOW MASTER STATUS\\G\n```\n\n### Replica\n\n```ini\n# \u002Fetc\u002Fmysql\u002Fmysql.conf.d\u002Fmysqld.cnf\n[mysqld]\nserver-id  = 2\nrelay_log  = \u002Fvar\u002Flog\u002Fmysql\u002Frelay-bin\nread_only  = ON\n```\n\n```sql\n-- Point replica to source (use SHOW MASTER STATUS values)\nCHANGE REPLICATION SOURCE TO\n  SOURCE_HOST     = '10.0.0.1',\n  SOURCE_USER     = 'replicator',\n  SOURCE_PASSWORD = '...', -- supply the replication secret securely\n  SOURCE_LOG_FILE = 'mysql-bin.000003',\n  SOURCE_LOG_POS  = 154;\n\nSTART REPLICA;\n\n-- Verify\nSHOW REPLICA STATUS\\G\n-- Check: Replica_IO_Running = Yes, Replica_SQL_Running = Yes, Seconds_Behind_Source = 0\n```\n\n## Monitoring Queries\n\n```sql\n-- Connection statistics\nSHOW STATUS LIKE 'Threads_connected';\nSHOW STATUS LIKE 'Max_used_connections';\n\n-- InnoDB buffer pool hit ratio (should be > 99%)\nSELECT\n  ROUND(100 - (\n    (SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME = 'Innodb_buffer_pool_reads') \u002F\n    (SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME = 'Innodb_buffer_pool_read_requests')\n  ) * 100, 2) AS buffer_pool_hit_pct;\n\n-- Top 10 slow queries (requires performance_schema)\nSELECT DIGEST_TEXT, COUNT_STAR, AVG_TIMER_WAIT \u002F 1e12 AS avg_sec\nFROM performance_schema.events_statements_summary_by_digest\nORDER BY AVG_TIMER_WAIT DESC\nLIMIT 10;\n\n-- Table sizes\nSELECT table_name,\n       ROUND(data_length \u002F 1024 \u002F 1024, 2) AS data_mb,\n       ROUND(index_length \u002F 1024 \u002F 1024, 2) AS index_mb,\n       table_rows\nFROM information_schema.tables\nWHERE table_schema = 'mydb'\nORDER BY data_length DESC;\n\n-- Check replication lag\nSHOW REPLICA STATUS\\G\n-- Look at Seconds_Behind_Source\n```\n\n## Docker Compose Setup\n\n```yaml\n# docker-compose.yml\nversion: \"3.9\"\n\nservices:\n  mysql:\n    image: mysql:8.0\n    restart: unless-stopped\n    ports:\n      - \"127.0.0.1:3306:3306\"\n    environment:\n      MYSQL_ROOT_PASSWORD: rootpass\n      MYSQL_DATABASE: mydb\n      MYSQL_USER: myapp\n      MYSQL_PASSWORD: secret\n    volumes:\n      - mysql_data:\u002Fvar\u002Flib\u002Fmysql\n      - .\u002Finit.sql:\u002Fdocker-entrypoint-initdb.d\u002Finit.sql\n    command: >\n      --innodb-buffer-pool-size=512M\n      --max-connections=200\n      --slow-query-log=ON\n      --long-query-time=1\n      --character-set-server=utf8mb4\n      --collation-server=utf8mb4_unicode_ci\n    healthcheck:\n      test: [\"CMD\", \"mysqladmin\", \"ping\", \"-h\", \"localhost\", \"-u\", \"root\", \"-prootpass\"]\n      interval: 10s\n      timeout: 5s\n      retries: 5\n\n  phpmyadmin:\n    image: phpmyadmin:latest\n    restart: unless-stopped\n    ports:\n      - \"127.0.0.1:8080:80\"\n    environment:\n      PMA_HOST: mysql\n      PMA_USER: root\n      PMA_PASSWORD: rootpass\n    depends_on:\n      mysql:\n        condition: service_healthy\n\nvolumes:\n  mysql_data:\n```\n\n```bash\ndocker compose up -d\nmysql -h 127.0.0.1 -u myapp -psecret mydb\n```\n\n## Maintenance Tasks\n\n```bash\n# Optimize a fragmented table (locks the table briefly)\nmysql -u root -p -e \"OPTIMIZE TABLE mydb.orders;\"\n\n# Analyze tables to update statistics\nmysql -u root -p -e \"ANALYZE TABLE mydb.orders;\"\n\n# Check and repair a table\nmysql -u root -p -e \"CHECK TABLE mydb.orders;\"\nmysql -u root -p -e \"REPAIR TABLE mydb.orders;\"\n\n# Rotate slow query log\nsudo mv \u002Fvar\u002Flog\u002Fmysql\u002Fslow.log \u002Fvar\u002Flog\u002Fmysql\u002Fslow.log.old\nmysqladmin -u root -p flush-logs\n```\n\n## Troubleshooting\n\n| Symptom | Likely Cause | Fix |\n|---|---|---|\n| `Too many connections` | Connection limit exceeded | Increase `max_connections`; use connection pooling (ProxySQL) |\n| Slow queries across the board | `innodb_buffer_pool_size` too small | Set to ~70% of available RAM and restart |\n| Replication stopped (`SQL_Running: No`) | Duplicate key or schema mismatch on replica | Check `SHOW REPLICA STATUS\\G` error; skip or fix the row |\n| `Table is full` | Disk space exhausted or table limit hit | Free disk space; check `innodb_data_file_path` autoextend |\n| `Lock wait timeout exceeded` | Long-running transaction holding row locks | Identify with `SHOW ENGINE INNODB STATUS`; kill the blocking query |\n| High IOPS \u002F disk usage | Redo log too small causing frequent flushes | Increase `innodb_log_file_size` (requires restart) |\n\n## Related Skills\n\n- postgresql (`postgresql-devsec`) - Alternative relational database\n- database-backups (`database-backups`) - Automated backup strategies\n- redis (`redis`) - Caching layer to reduce database load\n- planetscale (`planetscale`) - Managed MySQL-compatible with branching\n\n## Limitations\n\n- Infrastructure commands can disrupt services: confirm target host\u002Fscope and have backups\u002Fsnapshots before mutating state.\n- Docs-only import: upstream scripts and templates not bundled.\n\n",{"name":5,"risk":24,"source":44,"license":14,"category":45,"metadata":46,"date_added":49,"description":7,"source_repo":50,"source_type":18,"compatibility":51,"license_source":52},"https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills","devops",{"author":47,"version":48},"devops-skills","1.0","2026-09-20","BagelHole\u002FDevOps-Security-Agent-Skills","Requires the relevant OS\u002Fplatform tooling and privileged access where noted. Docs-only; helper scripts and templates not bundled.","https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\u002Fblob\u002Fmain\u002FLICENSE","7bf2279c8a65758319526a721d5c4b75683aec9c","skills\u002Fantigravity-mysql",3,"https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections","https:\u002F\u002Fgithub.com\u002Fboisenoise","2026-11-11 14:20:43",{"source":8,"skillName":5,"commands":60,"prompt":70,"zipAvailable":71},[61,64,67],{"tool":62,"command":63},"npx","npx skills add boisenoise\u002Fskills-collections --skill mysql",{"tool":65,"command":66},"bunx","bunx skills add boisenoise\u002Fskills-collections --skill mysql",{"tool":68,"command":69},"pnpm","pnpm dlx skills add boisenoise\u002Fskills-collections --skill mysql","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-mysql\u002FSKILL.md",true,[],[74,98,125,151,170,193],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":78,"licenseFileUrl":79,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":39},"01M6WNH92BHVFXHGPDZCPJ0AG0","web-access","Use Treg for public web or platform data only when existing search, browser and connected tools cannot cover the task, with explicit cost and data boundaries.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-web-access\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-web-access\u002FSKILL.md",[],[83,35,84,85,86,87,88,89,90,91,92,33,93,94,26,24,95,96,97,20,19],"web","web access","official","development","browser","search","data","Tools","read","fetch","youtube","free tools","free","cover","normal",{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":78,"licenseFileUrl":102,"sourceHtmlUrl":103,"categories":104,"keywords":110,"publishedAt":39},"01M6WNF9XAYAB2CZDDJBAKNM93","treg","Use the Treg CLI or MCP catalog to discover, price and call authorized external tools with team-scoped credentials and a user-approved budget.","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-treg\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-treg\u002FSKILL.md",[105],{"categoryNo":106,"categoryName":107,"taxonomyType":108,"taxonomyTypeDesc":109},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[100,111,112,113,85,86,37,90,114,115,116,117,118,119,120,24,121,122,123,124,19],"MCP","cli","github","Budget","credentials","team","catalog","use","call","discover","external tools","with","scoped","blob",{"skillNo":126,"name":127,"nameZh":6,"description":128,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":78,"licenseFileUrl":129,"sourceHtmlUrl":130,"categories":131,"keywords":137,"publishedAt":39},"01M6WN93MEAZ4E41DYAHJRPHQT","recruit","Turn a job description into an evidence-linked candidate shortlist through Treg, with job-related ranking and optional authorized business contact enrichment.","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-recruit\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-recruit\u002FSKILL.md",[132],{"categoryNo":133,"categoryName":134,"taxonomyType":135,"taxonomyTypeDesc":136},"01JBSEEDCAT000000000000038","人力资源","PROFESSION","适用职业",[127,113,85,37,138,139,140,141,142,143,24,144,145,146,122,147,148,149,150,124,100,19],"https","email","enrichment","business","evidence","phone","ranking","post","job description","for","person","candidate","reason",{"skillNo":152,"name":153,"nameZh":6,"description":154,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":78,"licenseFileUrl":155,"sourceHtmlUrl":156,"categories":157,"keywords":158,"publishedAt":39},"01M6WN8R5RXSMHM9B4D9FAFX42","rea-growth","Analyze a company’s public growth and content through Treg, distinguish observations from hypotheses, and produce an evidence-linked playbook within an approved budget.","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-rea-growth\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-rea-growth\u002FSKILL.md",[],[159,160,161,113,85,37,162,163,138,164,114,165,166,167,142,24,168,169,124,100,19],"growth","rea","rea growth","produce","content","playbook","marketing","analyze","public","observations","company",{"skillNo":171,"name":172,"nameZh":6,"description":173,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":78,"licenseFileUrl":174,"sourceHtmlUrl":175,"categories":176,"keywords":177,"publishedAt":39},"01M6WN2EVE3RQRGWAKBT4S7YT2","make-ugc","Create original AI UGC-style product videos through Treg: research hooks, approve a licensed presenter and voice, generate clips, add captions and report costs.","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-make-ugc\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-make-ugc\u002FSKILL.md",[],[178,179,113,180,85,181,37,182,183,184,185,186,24,187,188,189,190,191,192,124],"make","make ugc","research","create","Video","Captions","ads","short","hooks","head","style","niche","trending","talking-head","approve",{"skillNo":194,"name":195,"nameZh":6,"description":196,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":78,"licenseFileUrl":197,"sourceHtmlUrl":198,"categories":199,"keywords":200,"publishedAt":39},"01M6WN10ARAA63Y8K1YNGXJ2RM","lead-signals","Find and qualify public buying signals through Treg, rank fitting business accounts and optionally enrich authorized business contact information.","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-lead-signals\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-lead-signals\u002FSKILL.md",[],[201,202,203,113,85,37,204,205,141,206,207,24,208,209,210,211,212,213,214,124],"signals","lead","lead signals","how","find","ready","as","how to","qualify","people","information","enrich","changes","funding"]