mysql
БесплатноБез исполняемых скриптовНе проверенMySQL is an open-source relational database server. Use when you need to install MySQL, design tables, add indexes, write queries, set up replication, take…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
MySQL
Overview
MySQL is a relational database used from small apps to large web platforms, with ACID transactions (InnoDB), replication and full-text search. Current releases are the 8.4 and 9.7 LTS lines and the 26.x innovation line. MySQL 8.0 reached end of life in April 2026, so new installs should use 8.4 or 9.7. The snippets below were run on 9.7.4.
Instructions
Install the server, create a schema with utf8mb4 and InnoDB, index the columns your queries filter on, and connect with a pooled driver using parameterised queries.
Installation
# Docker (recommended for development)
# tags: mysql:9.7 (LTS), mysql:8.4 (LTS), mysql:lts; mysql:8 now points at 8.4
docker run -d --name mysql -p 127.0.0.1:3306:3306 \
-e MYSQL_ROOT_PASSWORD="$MYSQL_ROOT_PASSWORD" \
-e MYSQL_DATABASE=myapp \
mysql:9.7
# Ubuntu/Debian (installs the version Ubuntu ships, check it is 8.4 or newer)
sudo apt-get install mysql-server
sudo mysql_secure_installation
# macOS
brew install mysql && brew services start mysql
# Node.js driver
npm install mysql2
# Python driver
pip install mysql-connector-python
CLI Basics
# Connect to MySQL
mysql -u root -p
# Connect to specific database
mysql -u root -p myapp
# Execute query from command line
mysql -u root -p -e "SHOW DATABASES;"
# Import SQL file
mysql -u root -p myapp < schema.sql
# Export database
mysqldump -u root -p myapp > backup.sql
Schema Design
-- schema.sql: Create tables with proper types, indexes, and constraints
CREATE DATABASE IF NOT EXISTS myapp CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE myapp;
CREATE TABLE users (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(255) NOT NULL UNIQUE,
name VARCHAR(100) NOT NULL,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX idx_created (created_at)
) ENGINE=InnoDB;
CREATE TABLE orders (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
user_id BIGINT UNSIGNED NOT NULL,
total_cents INT UNSIGNED NOT NULL DEFAULT 0,
status ENUM('pending','paid','shipped','completed','cancelled') DEFAULT 'pending',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
INDEX idx_user_status (user_id, status)
) ENGINE=InnoDB;
Indexing Strategies
-- indexing.sql: Common indexing patterns for performance
-- Composite index for multi-column queries (leftmost prefix rule)
CREATE INDEX idx_orders_status_date ON orders(status, created_at);
-- Covering index — query answered entirely from index
CREATE INDEX idx_users_email_name ON users(email, name);
-- Full-text index for search (assumes a products table with name and description)
ALTER TABLE products ADD FULLTEXT INDEX ft_search (name, description);
SELECT * FROM products WHERE MATCH(name, description) AGAINST('laptop' IN BOOLEAN MODE);
-- Check query execution plan
EXPLAIN ANALYZE SELECT * FROM orders WHERE user_id = 42 AND status = 'paid';
Node.js with mysql2
// db.js: MySQL connection pool with mysql2 and promise API
const mysql = require('mysql2/promise');
const pool = mysql.createPool({
host: process.env.DB_HOST || 'localhost',
user: process.env.DB_USER || 'root',
password: process.env.DB_PASS,
database: 'myapp',
waitForConnections: true,
connectionLimit: 10,
charset: 'utf8mb4',
});
async function getUser(id) {
const [rows] = await pool.execute(
'SELECT id, email, name FROM users WHERE id = ?',
[id]
);
return rows[0] || null;
}
async function createOrder(userId, totalCents) {
const conn = await pool.getConnection();
try {
await conn.beginTransaction();
const [result] = await conn.execute(
'INSERT INTO orders (user_id, total_cents) VALUES (?, ?)',
[userId, totalCents]
);
await conn.commit();
return result.insertId;
} catch (err) {
await conn.rollback();
throw err;
} finally {
conn.release();
}
}
module.exports = { pool, getUser, createOrder };
Python Client
# db.py: MySQL connection with mysql-connector-python
import os
import mysql.connector
from mysql.connector import pooling
pool = pooling.MySQLConnectionPool(
pool_name="myapp",
pool_size=5,
host="localhost",
user="root",
password=os.environ["DB_PASS"],
database="myapp",
charset="utf8mb4",
)
def get_user(user_id):
conn = pool.get_connection()
try:
cursor = conn.cursor(dictionary=True)
cursor.execute("SELECT id, email, name FROM users WHERE id = %s", (user_id,))
return cursor.fetchone()
finally:
conn.close()
def insert_users(users):
conn = pool.get_connection()
try:
cursor = conn.cursor()
cursor.executemany(
"INSERT INTO users (email, name, password_hash) VALUES (%s, %s, %s)",
users,
)
conn.com
Установить mysql в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл mysql?
MySQL is an open-source relational database server. Use when you need to install MySQL, design tables, add indexes, write queries, set up replication, take backups, or connect from Node.js (mysql2) or Python (mysql-connector-python).
Как установить скилл mysql?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл mysql запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic