# mcp-mysql-server

> mcp-mysql-server is an open-source MCP server for databases. MCP server giving AI assistants query and schema access to MySQL databases. It is available on CLI and Self-hosted.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, Self-hosted
- **Repository:** https://github.com/f4ww4z/mcp-mysql-server
- **GitHub stars:** 171
- **License:** MIT
- **Categories:** [databases](https://ai-powered.com/categories/databases)
- **Listing updated:** 2026-12-01

## About

This server bridges MySQL and any Model Context Protocol client, so an assistant can connect to a database, read table layouts, run SELECT statements and perform writes without leaving the chat. It is started with npx and configured through a connection URL or separate host, user, password and database environment variables.

Queries accept optional placeholder parameters, which keeps user-supplied values out of the raw SQL text. Connections are opened and closed by the server, so clients do not have to manage them manually. Setup instructions are included for Claude Desktop via Smithery and for the Codex configuration file on macOS and Windows.

It suits developers and data analysts who want an assistant to explore a MySQL schema or pull figures from a database they already run. Because it can also execute INSERT, UPDATE and DELETE statements, it is best pointed at a database account with limited privileges.

## Features

- **Schema exploration:** Lists the tables in the connected database and shows the structure of any chosen table.
- **Parameterised SELECT queries:** Runs read queries with placeholder values passed separately from the SQL text.
- **Write operations:** Executes INSERT, UPDATE and DELETE statements with optional bound parameters.
- **Flexible connection setup:** Accepts a single MySQL connection URL or individual host, user, password and database variables.
- **Automatic connection handling:** Opens database connections as needed and closes them when work is finished.
- **Client configuration examples:** Provides ready-to-copy config snippets for Claude Desktop and Codex on macOS and Windows.

## Good for

- Letting an assistant answer questions about data stored in a MySQL database
- Inspecting an unfamiliar schema by listing tables and their columns
- Generating reports by running read-only SELECT queries from a chat
- Adding or updating rows in a development database during prototyping
- Testing SQL statements interactively before using them in an application

## Tools

From the tool list in its README, going by the names, 1 of 5 tools changes data; 1 name doesn't say. From the server's own tool labels and tool names; not verified by us.

- `connect_db`: Establish connection to MySQL database using provided credentials.
- `query` (name suggests: reads): Execute SELECT queries with optional prepared statement parameters.
- `execute` (name suggests: changes): Execute INSERT, UPDATE, or DELETE queries with optional prepared statement parameters.
- `list_tables` (name suggests: reads): List all tables in the connected database.
- `describe_table` (name suggests: reads): Get the structure of a specific table.

## FAQ

### What license is mcp-mysql-server released under?

It is released under the MIT license.

### How is the server installed?

It can be installed through Smithery for Claude Desktop, or run directly with npx using the package name @f4ww4z/mcp-mysql-server.

### How are database credentials supplied?

They can be passed as a MySQL connection URL in the server arguments, or as MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD and MYSQL_DATABASE environment variables.

### Does mcp-mysql-server protect against SQL injection?

Queries can use prepared statement parameters, which the server describes as its protection against SQL injection.

### Is mcp-mysql-server free?

Yes. mcp-mysql-server is open source, so you can use and self-host it for free.

### What are the best alternatives to mcp-mysql-server?

The closest alternatives to mcp-mysql-server are mysql_mcp_server, mcp-server-mysql, mysql-mcp-server, postgres_mcp and MySQL Ops MCP.

## Where this comes from

- Description: written from the project's README.

## Alternatives

- [mysql_mcp_server](https://ai-powered.com/mcp/mysql-mcp-server-4): mysql_mcp_server is an open-source MCP server for databases.
- [mcp-server-mysql](https://ai-powered.com/mcp/mcp-server-mysql): mcp-server-mysql is an open-source MCP server for databases.
- [mysql-mcp-server](https://ai-powered.com/mcp/mysql-mcp-server-3): mysql-mcp-server is an open-source MCP server for databases.
- [postgres_mcp](https://ai-powered.com/mcp/postgres-mcp-5): postgres_mcp is an open-source MCP server for databases.
- [MySQL Ops MCP](https://ai-powered.com/mcp/mysql-ops-mcp): MySQL Ops MCP is an open-source MCP server for databases.
- [MySQL MCP Server](https://ai-powered.com/mcp/mysql-mcp-server): MySQL MCP Server is an open-source MCP server for databases.
- [MCP Mysql Connector](https://ai-powered.com/mcp/mcp-mysql-connector): MCP Mysql Connector is an open-source MCP server for databases.
- [mcp-alchemy](https://ai-powered.com/mcp/mcp-alchemy): mcp-alchemy is an open-source MCP server for databases.

---
Source: https://ai-powered.com/mcp/mcp-mysql-server
