You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "Ikarashi0310 (via GitHub)" <gi...@apache.org> on 2025/09/17 14:53:49 UTC
[D] Could not load database driver: MySQLEngineSpec [superset]
GitHub user Ikarashi0310 created a discussion: Could not load database driver: MySQLEngineSpec
I'm encountering an issue when trying to connect to a MySQL database from a custom Superset Docker image built using the **latest** tag.
The error message I receive is:
**`Could not load database driver: MySQLEngineSpec`**
### Context
1. **Working Scenario (Master Tag):** When I used a custom image based on the **`master`** Docker image tag (from a while ago), the MySQL connection worked perfectly without any additional driver installation steps in my custom Dockerfile.
2. **Failing Scenario (Latest Tag):** After switching my base image to the **`latest`** tag, I started seeing this driver loading error.
3. **My Setup:**
* I'm using a **custom Dockerfile** based on the official Apache Superset image (`apache/superset:latest`).
* The MySQL instance is running on a separate container (via Docker Compose).
### My Question
It seems the necessary Python database driver (like `mysqlclient` or `PyMySQL`) might no longer be pre-installed in the `latest` image by default, whereas it was likely included in the older `master` image.
Could someone confirm if this is the case?
If so, what is the **recommended method** to reliably install the MySQL driver (`mysqlclient` or other) into the current **`latest`** Superset Docker image for a production-like environment?
I'd appreciate any guidance or pointers to the relevant documentation or a best-practice Dockerfile snippet.
Thank you in advance for your help!
```
FROM apache/superset:latest
USER root
RUN apt-get update && apt-get install -y \
pkg-config \
default-libmysqlclient-dev \
gcc \
libssl-dev \
curl \
&& rm -rf /var/lib/apt/lists/*
USER superset
RUN pip install mysqlclient pymysql psycopg2
CMD ["superset", "run", "-h", "0.0.0.0", "-p", "8088", "--with-threads", "--reload"]
```
GitHub link: https://github.com/apache/superset/discussions/35175
----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [D] Could not load database driver: MySQLEngineSpec [superset]
Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
GitHub user msyavuz added a comment to the discussion: Could not load database driver: MySQLEngineSpec
Hey @Ikarashi0310, I think this might be what you are looking for: https://superset.apache.org/docs/configuration/databases#installing-drivers-in-docker-images
GitHub link: https://github.com/apache/superset/discussions/35175#discussioncomment-14435221
----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [D] Could not load database driver: MySQLEngineSpec [superset]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
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> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&
nbsp;[](https://go.dosu.dev/discord-bot) [](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 notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [D] Could not load database driver: MySQLEngineSpec [superset]
Posted by "Ikarashi0310 (via GitHub)" <gi...@apache.org>.
GitHub user Ikarashi0310 closed a discussion: Could not load database driver: MySQLEngineSpec
I'm encountering an issue when trying to connect to a MySQL database from a custom Superset Docker image built using the **latest** tag.
The error message I receive is:
**`Could not load database driver: MySQLEngineSpec`**
### Context
1. **Working Scenario (Master Tag):** When I used a custom image based on the **`master`** Docker image tag (from a while ago), the MySQL connection worked perfectly without any additional driver installation steps in my custom Dockerfile.
2. **Failing Scenario (Latest Tag):** After switching my base image to the **`latest`** tag, I started seeing this driver loading error.
3. **My Setup:**
* I'm using a **custom Dockerfile** based on the official Apache Superset image (`apache/superset:latest`).
* The MySQL instance is running on a separate container (via Docker Compose).
### My Question
It seems the necessary Python database driver (like `mysqlclient` or `PyMySQL`) might no longer be pre-installed in the `latest` image by default, whereas it was likely included in the older `master` image.
Could someone confirm if this is the case?
If so, what is the **recommended method** to reliably install the MySQL driver (`mysqlclient` or other) into the current **`latest`** Superset Docker image for a production-like environment?
I'd appreciate any guidance or pointers to the relevant documentation or a best-practice Dockerfile snippet.
Thank you in advance for your help!
```
FROM apache/superset:latest
USER root
RUN apt-get update && apt-get install -y \
pkg-config \
default-libmysqlclient-dev \
gcc \
libssl-dev \
curl \
&& rm -rf /var/lib/apt/lists/*
USER superset
RUN pip install mysqlclient pymysql psycopg2
CMD ["superset", "run", "-h", "0.0.0.0", "-p", "8088", "--with-threads", "--reload"]
```
GitHub link: https://github.com/apache/superset/discussions/35175
----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [D] Could not load database driver: MySQLEngineSpec [superset]
Posted by "Ikarashi0310 (via GitHub)" <gi...@apache.org>.
GitHub user Ikarashi0310 added a comment to the discussion: Could not load database driver: MySQLEngineSpec
@dosu
"I was able to use MySQL after switching from pip install to uv pip install! Thank you so much!"
@msyavuz
"And thank you! Your information was very helpful."
GitHub link: https://github.com/apache/superset/discussions/35175#discussioncomment-14436139
----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [D] Could not load database driver: MySQLEngineSpec [superset]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] edited a comment on 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?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).*
---
Docs are dead. Just use [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-tagline&utm_term=apache%2Fsuperset).
[](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-feedback&utm_term=apache%2Fsuperset&message_id=ea8869dc-3817-44f3-a192-0ff8629fe76b) [](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-ask-repo&utm_term=apache%2Fsuperset) [](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-share-team&utm_term=apache%2Fsuperset)
GitHub link: https://github.com/apache/superset/discussions/35175#discussioncomment-14430552
----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org