# Mysql

> Administer MySQL/MariaDB databases. Configure replication and optimize performance. Use when managing MySQL deployments.

- Skill: `majiayu000/mysql-5` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds add majiayu000/mysql-5`
- Raw SKILL.md: https://api.skillmd.com/api/skills/majiayu000/mysql-5/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- License: MIT
- Author: majiayu000 (https://skillmd.com/u/majiayu000)
- Updated: 2026-09-09
- Page: https://skillmd.com/skills/majiayu000/mysql-5

---


# MySQL / MariaDB

Administer MySQL and MariaDB databases.

## Installation & Setup

```bash
# Install
apt install mysql-server

# Secure installation
mysql_secure_installation

# Access
mysql -u root -p

# Create database and user
CREATE DATABASE mydb;
CREATE USER 'myapp'@'%' IDENTIFIED BY 'secret';
GRANT ALL PRIVILEGES ON mydb.* TO 'myapp'@'%';
FLUSH PRIVILEGES;
```

## Configuration

```bash
# /etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld]
innodb_buffer_pool_size = 1G
max_connections = 200
slow_query_log = 1
long_query_time = 2
```

## Backup & Restore

```bash
# Backup
mysqldump -u root -p mydb > backup.sql
mysqldump -u root -p --all-databases > full_backup.sql

# Restore
mysql -u root -p mydb < backup.sql
```

## Replication

```bash
# Primary
[mysqld]
server-id = 1
log_bin = mysql-bin

# Replica
CHANGE MASTER TO
  MASTER_HOST='primary',
  MASTER_USER='replicator',
  MASTER_PASSWORD='secret',
  MASTER_LOG_FILE='mysql-bin.000001',
  MASTER_LOG_POS=0;
START SLAVE;
```

## Best Practices

- Enable slow query logging
- Use InnoDB storage engine
- Regular backups with mysqldump
- Monitor with SHOW PROCESSLIST

