Skip to main content
MCP server CX Codex

database-mcp-mysql — Claude Code MCP server: how to install

Connects AI assistants to MySQL instances with read-only safeguards. Useful for exploring schemas and inspecting data without write hazards.

Install into Claude Code · Platform CLI All methods and platforms ↓
claude mcp add database-mcp-mysql -e MYSQL_HOST=<MYSQL_HOST> -e MYSQL_USER=<MYSQL_USER> -e MYSQL_PASSWORD=<MYSQL_PASSWORD> -e MYSQL_DATABASE=<MYSQL_DATABASE> -- npx -y @database-mcp/mysql
Open on GitHub

What database-mcp-mysql does

The server provides two tools for AI models: search_objects and execute_sql. Running the schema inspector without arguments outputs table names. Supplying a table name reveals its column types, indexes, and foreign keys. The second tool runs the queries.

Safeguards protect against database mutations on two fronts. The tool checks statements before execution and sets a read-only session inside MySQL. Default limits restrict output to 1000 rows and stop commands after 30 seconds.

Database credentials cannot be passed inside chat prompts. The process reads configuration exclusively on startup from flags, a YAML document, or MYSQL_* environment variables.

What it helps with

  • inspect MySQL tables, indexes, and foreign keys
  • run analytical SQL queries without accidental writes
  • cut off slow database statements with a 30-second timeout
  • keep connection passwords out of application logs

Example prompts for the agent

  • Inspect the schema of the customers table and list its indexes.
  • Find the five most recent entries in the orders table.
  • List every table present in the current MySQL database.

How to install database-mcp-mysql

Platform CLI

claude mcp add database-mcp-mysql -e MYSQL_HOST=<MYSQL_HOST> -e MYSQL_USER=<MYSQL_USER> -e MYSQL_PASSWORD=<MYSQL_PASSWORD> -e MYSQL_DATABASE=<MYSQL_DATABASE> -- npx -y @database-mcp/mysql

Replace <…> with your own values

Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more

Questions about database-mcp-mysql

How to install database-mcp-mysql in Claude Code?

Run `claude mcp add database-mcp-mysql -e MYSQL_HOST=<MYSQL_HOST> -e MYSQL_USER=<MYSQL_USER> -e MYSQL_PASSWORD=<MYSQL_PASSWORD> -e MYSQL_DATABASE=<MYSQL_DATABASE> -- npx -y @database-mcp/mysql`. Replace placeholder tags with actual MySQL credentials.

What does database-mcp-mysql do?

It exposes MySQL to coding agents via two tools: search_objects to explore schemas and execute_sql to fetch data safely.

Can I supply database passwords inside the conversation?

No, the server rejects credentials sent through prompts. All connection details must be configured upfront via environment variables, flags, or YAML files.

Similar MCP servers

All MCP servers for Data and databases →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor