Skip to content

MySQL Shell

Chris edited this page Jul 17, 2026 · 110 revisions

MySQL Shell

Tools Resources Prompts
OAuth Code Mode

Value Proposition Seamlessly orchestrate parallel imports, comprehensive instance dumps, and robust script execution at enterprise scale. Read the full value proposition.


Enterprise Prerequisites

  • MySQL Shell binary accessible (in PATH or via environment variable)
  • Version Compatibility: MySQL Shell version should match your MySQL Server version

Warning

Version Mismatch: Ensure your Shell version matches your server version.


Browse Available Tools

Includes, but is not limited to:

Tool Description Parameters
mysqlsh_version Get MySQL Shell version and installation status -
mysqlsh_check_upgrade Check server upgrade compatibility targetVersion
mysqlsh_export_table Export table to file (CSV, TSV) schema, table, file
mysqlsh_import_table Parallel table import from file. file, schema, table, updateServerSettings
mysqlsh_import_json Import JSON documents to collection or table file, schema, collection
mysqlsh_dump_instance Dump entire MySQL instance outputDir
mysqlsh_dump_schemas Dump selected schemas. ddlOnly dumps only DDL schemas, outputDir, ddlOnly
mysqlsh_dump_tables Dump specific tables. all controls trigger inclusion schema, tables, outputDir, all
mysqlsh_load_dump Load MySQL Shell dump. dumpDir, updateServerSettings
mysqlsh_run_script Execute JS/Python/SQL script via MySQL Shell code, language

Validate Pre-flight Operational Requirements

Tool Requirements
mysqlsh_import_json Requires X Protocol (typically port 33060) for collection imports. NDJSON format only
mysqlsh_import_table Requires target tables to have a PRIMARY KEY when importing to InnoDB Cluster
mysqlsh_load_dump / mysqlsh_import_table Requires local_infile=ON in MySQL Server config. Use updateServerSettings to auto-enable it.
mysqlsh_check_upgrade User needs RELOAD, PROCESS, SELECT privileges
mysqlsh_dump_* / mysqlsh_load_dump Shell version should match server version
mysqlsh_run_script Operates under standard execution boundaries but explicitly requires the OAuth admin scope

Optimize Operational Readiness

1. Verify Installation

mysqlsh --version
# Expected: mysqlsh   Ver <version> for ...

2. Enable local_infile (for mysqlsh_load_dump)

SET GLOBAL local_infile = 1;

Or add to my.cnf:

[mysqld]
local_infile=ON

3. Verify X Protocol (for mysqlsh_import_json)

mysqlsh --uri root@localhost:33060 --sql -e "SELECT 1"

Configure Your Environment

Variable Default Description
MYSQLSH_PATH mysqlsh Path to MySQL Shell binary
MYSQLSH_WORK_DIR Current directory Working directory for dump/load operations
MYSQLSH_TIMEOUT 300000 Command timeout in milliseconds (5 min)
MYSQL_XPORT 33060 X Protocol port (for mysqlsh_import_json)

Warning

If your shell operations are expected to exceed the default HTTP request timeout, increase MCP_REQUEST_TIMEOUT to prevent dropped connections. This applies specifically when using HTTP/SSE clients, not standard stdio. When running heavy HTTP migrations, explicitly align MCP_REQUEST_TIMEOUT with MYSQLSH_TIMEOUT.

[!WARNING] MySQL Shell commands execute as subprocesses. Ensure proper file permissions. Configure --allowed-io-roots to permit sandbox access.


Integrate the Server

{
  "mcpServers": {
    "mysql-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@neverinfamous/mysql-mcp",
        "--transport", "stdio",
        "--mysql", "mysql://user:password@localhost:3306/database",
        "--allowed-io-roots", "C:/temp",
        "--allowed-io-roots", "/tmp"
      ],
      "env": {
        "MYSQLSH_PATH": "mysqlsh"
      }
    }
  }
}

Isolate Your Workloads

If you only want MySQL Shell tools (e.g., for a dedicated migration agent):

{
  "args": [
    "--transport", "stdio",
    "--tool-filter", "shell"
  ]
}

This exposes only the MySQL Shell management tools.

Explore Related Topics

Ensure Safe Parsing

The mysqlsh_* tools use Zod for robust input validation. You can use Zod's native .safeParse() method to safely handle unexpected parameters, or integrate using the Standard Schema specification via the ~standard interface for broader interoperability. Semantic validation still depends on the database engine.

MySQL MCP Documentation

Value Proposition Enforce strict execution boundaries and maximize LLM context efficiency for secure, autonomous database interactions. Read the full value proposition

🏠 Home


Launch Your Setup


Connect Ecosystem Tools


Security & Compliance


Scale Your Operations


Explore External Links

Clone this wiki locally