# Quick Start Guide
Get up and running with MCP MySQL Server in 5 minutes!
## Prerequisites
- **Either** Bun (recommended, faster) **OR** Node.js 18+
- MySQL database
- Claude Code or Codex CLI installed
## Option 1: Automated Setup (Recommended)
```bash
# Run the setup script (auto-detects Bun or npm)
./setup.sh
# Follow the interactive prompts to configure your database
```
The setup script will:
- Auto-detect Bun or Node.js/npm
- Install dependencies
- Create .env file
- Build the project
- Test database connection
## Option 2: Manual Setup with Bun (Faster)
```bash
# 1. Install dependencies
bun install
# 2. Configure environment
cp .env.example .env
nano .env # Edit with your MySQL credentials
# 3. Build the project
bun run build
```
## Option 3: Manual Setup with npm
```bash
# 1. Install dependencies
npm install
# 2. Configure environment
cp .env.example .env
nano .env # Edit with your MySQL credentials
# 3. Build the project
npm run build
```
## Configuration
Edit `.env` with your MySQL credentials:
```env
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=your_username
MYSQL_PASS=your_password
MYSQL_DB=your_database
# Safety settings (recommended defaults)
ALLOW_INSERT_OPERATION=false
ALLOW_UPDATE_OPERATION=false
ALLOW_DELETE_OPERATION=false
```
## For Claude Code Users
Add to `~/.config/claude-code/.mcp.json`:
```json
{
"mcpServers": {
"mysql": {
"command": "node",
"args": ["/absolute/path/to/mcp-mysql-server/dist/index.js"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "your_username",
"MYSQL_PASS": "your_password",
"MYSQL_DB": "your_database",
"ALLOW_INSERT_OPERATION": "false",
"ALLOW_UPDATE_OPERATION": "false",
"ALLOW_DELETE_OPERATION": "false"
}
}
}
}
```
**Note:** Replace `/absolute/path/to/` with the actual path to your installation.
Restart Claude Code, and you're ready!
## For Codex CLI Users
Same configuration as Claude Code above, but add to your Codex CLI config file.
Start Codex CLI:
```bash
codex
```
## First Commands to Try
Once connected, try these in your MCP client:
1. **Check connection:**
```
Show me the MySQL database information
```
2. **List tables:**
```
What tables are in my database?
```
3. **Query data:**
```
Show me the first 10 rows from the users table
```
4. **Test safety features:**
```
Try to insert a test record
```
(Should be blocked with an error message)
## Troubleshooting
### Build Failed
```bash
# Clean and rebuild
npm run clean
npm run build
```
### Connection Issues
```bash
# Test MySQL connection
mysql -h localhost -u your_username -p your_database -e "SELECT 1"
```
### Server Not Found in MCP Client
- Check the path in your MCP config is absolute
- Verify `dist/index.js` exists: `ls -la dist/index.js`
- Restart your MCP client after configuration changes
## Next Steps
- Read the [complete documentation](README.md)
- Explore [usage examples](examples/usage-examples.md)
- Check out [Claude Code setup guide](examples/claude-code-setup.md)
- Review [Codex CLI setup guide](examples/codex-cli-setup.md)
## Safety First
By default, the server runs in **read-only mode**:
- ✅ SELECT queries allowed
- ❌ INSERT, UPDATE, DELETE blocked
- ❌ DROP, TRUNCATE, ALTER always blocked
This protects your database while you explore and analyze data.
## Getting Help
- Check the [examples](examples/) directory
- Read [CONTRIBUTING.md](CONTRIBUTING.md)
- Review the main [README.md](README.md)
- Open an issue on GitHub
Happy querying! 🎉