Skip to content

MySQL Shell

Temp edited this page Dec 13, 2025 · 1 revision

MySQL Shell Configuration

MySQL Shell tools provide advanced data operations using MySQL Shell 8.0+.


Prerequisites

  • MySQL Shell 8.0+ installed
  • MySQL Shell binary accessible (in PATH or via environment variable)
  • Version Compatibility: MySQL Shell version should match or be newer than your MySQL Server version

⚠️ Version Mismatch: MySQL Shell 8.0.x has limited compatibility with MySQL Server 9.x. For best results, ensure your MySQL Shell version matches your server version.


Available Tools (10)

Tool Description
mysqlsh_version Get MySQL Shell version and installation status
mysqlsh_check_upgrade Check server upgrade compatibility
mysqlsh_export_table Export table to file (CSV, TSV, JSON)
mysqlsh_import_table Parallel table import from file
mysqlsh_import_json Import JSON documents to collection or table
mysqlsh_dump_instance Dump entire MySQL instance
mysqlsh_dump_schemas Dump selected schemas
mysqlsh_dump_tables Dump specific tables
mysqlsh_load_dump Load MySQL Shell dump
mysqlsh_run_script Execute JS/Python/SQL script via MySQL Shell

Tool-Specific Requirements

Tool Requirements
mysqlsh_import_json Requires X Protocol (port 33060) for collection imports
mysqlsh_load_dump Requires local_infile=ON in MySQL Server config
mysqlsh_check_upgrade User needs RELOAD, PROCESS, SELECT privileges
mysqlsh_dump_* / mysqlsh_load_dump Shell version should match server version

Setting Up MySQL Shell

1. Verify Installation

mysqlsh --version
# Expected: mysqlsh   Ver 8.0.x 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"

Environment Variables

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 Shell commands execute as subprocesses. Ensure proper file system permissions for dump/load operations.


MCP Configuration

{
  "mcpServers": {
    "mysql-mcp": {
      "command": "node",
      "args": [
        "C:/path/to/mysql-mcp/dist/cli.js",
        "--transport", "stdio",
        "--mysql", "mysql://user:password@localhost:3306/database"
      ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "root",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "production",
        "MYSQLSH_PATH": "mysqlsh"
      }
    }
  }
}

Shell-Only Configuration

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

{
  "args": [
    "--transport", "stdio",
    "--mysql", "mysql://user:password@localhost:3306/database",
    "--tool-filter", "-core,-json,-text,-fulltext,-performance,-optimization,-admin,-monitoring,-backup,-replication,-partitioning,-transactions,-router,-proxysql"
  ]
}

This exposes only the 10 MySQL Shell management tools.


See Also

Clone this wiki locally