GitHub user dosubot[bot] added a comment to the discussion: Could not load 
database driver: MySQLEngineSpec

<!-- Greeting -->
Hi @Ikarashi0310! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the 
superset team.

<!-- Answer -->
You're correct—the MySQL Python drivers (like `mysqlclient` or `PyMySQL`) are 
no longer included by default in the latest Superset Docker images (starting 
from version 4.1.0) to keep the image leaner. This change means you now need to 
explicitly install the required drivers and their system dependencies in your 
custom image to connect to MySQL databases. 
[Reference](https://github.com/apache/superset/issues/31459) 
[Reference](https://github.com/apache/superset/issues/33875).

The recommended approach is to create a custom Dockerfile that installs the 
necessary system packages and then the Python driver. For recent Superset 
versions (5.x), it's best to use the new `uv` package manager instead of `pip` 
for Python dependencies. Here’s a best-practice snippet:

```dockerfile
FROM apache/superset:latest

USER root
RUN apt-get update && apt-get install -y \
    python3-dev \
    default-libmysqlclient-dev \
    build-essential \
    pkg-config \
    && rm -rf /var/lib/apt/lists/*

USER superset
RUN uv pip install --no-cache-dir mysqlclient pymysql

# Or, if you're on Superset 4.x, you can use pip:
# RUN pip install --no-cache-dir mysqlclient pymysql

CMD ["superset", "run", "-h", "0.0.0.0", "-p", "8088", "--with-threads", 
"--reload"]
```

Alternatively, you can add `mysqlclient` to a `requirements-local.txt` in your 
`docker` directory and rebuild your image, but you still need to ensure the 
system dependencies are installed in your Dockerfile. 
[Reference](https://github.com/apache/superset/issues/33875) 
[Reference](https://github.com/apache/superset/discussions/31432).

After making these changes, rebuild your Docker image and restart your 
containers. This will reliably enable MySQL support in your Superset deployment.


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/ea8869dc-3817-44f3-a192-0ff8629fe76b?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/ea8869dc-3817-44f3-a192-0ff8629fe76b?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/ea8869dc-3817-44f3-a192-0ff8629fe76b?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/ea8869dc-3817-44f3-a192-0ff8629fe76b?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/ea8869dc-3817-44f3-a192-0ff8629fe76b?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/ea8869dc-3817-44f3-a192-0ff8629fe76b?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/ea8869dc-3817-44f3-a192-0ff8629fe76b?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat
 with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&
 nbsp;[![Join 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/35175)

GitHub link: 
https://github.com/apache/superset/discussions/35175#discussioncomment-14430552

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to