我在docker上安装了mysql和apache超集,并通过网桥网络连接,SQLAlchemy URI是什么? [英] I have mysql and apache superset setup on dockers and connected by a bridge network, what will theSQLAlchemy URI be?

查看:158
本文介绍了我在docker上安装了mysql和apache超集,并通过网桥网络连接,SQLAlchemy URI是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拉了官方的超集图片:

I pulled the official superset image:

git clone https://github.com/apache/incubator-superset.git

然后将MYSQL客户端添加到requirements.txt

then added the MYSQL Client to requirements.txt

cd incubator-superset
touch ./docker/requirements-local.txt
echo "mysqlclient==1.4.6" >> ./docker/requirements-local.txt
docker-compose build --force-rm
docker-compose up -d

之后,我制作了MYSQL容器

After which I made the MYSQL Container

docker run --detach --network="incubator-superset_default" --name=vedasupersetmysql --env="MYSQL_ROOT_PASSWORD=vedashri" --publish 6603:3306 mysql

然后将Mysql连接到Superset Bridge.

Then connected Mysql to the Superset Bridge.

桥接网络如下:

docker inspect incubator-superset_default
[
    {
        "Name": "incubator-superset_default",
        "Id": "56db7b47ecf0867a2461dddb1219c64c1def8cd603fc9668d80338a477d77fdb",
        "Created": "2020-12-08T07:38:47.94934583Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.19.0.0/16",
                    "Gateway": "172.19.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": true,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "07a6e0d5d87ea3ccb353fa20a3562d8f59b00d2b7ce827f791ae3c8eca1621cc": {
                "Name": "superset_db",
                "EndpointID": "0dd4781290c67e3e202912cad576830eddb0139cb71fd348019298b245bc4756",
                "MacAddress": "02:42:ac:13:00:02",
                "IPv4Address": "172.19.0.2/16",
                "IPv6Address": ""
            },
            "096a98f22688107a689aa156fcaf003e8aaae30bdc3c7bc6fc08824209592a44": {
                "Name": "superset_worker",
                "EndpointID": "54614854caebcd9afd111fb67778c7c6fd7dd29fdc9c51c19acde641a9552e66",
                "MacAddress": "02:42:ac:13:00:05",
                "IPv4Address": "172.19.0.5/16",
                "IPv6Address": ""
            },
            "34e7fe6417b109fb9af458559e20ce1eaed1dc3b7d195efc2150019025393341": {
                "Name": "superset_init",
                "EndpointID": "49c580b22298237e51607ffa9fec56a7cf155065766b2d75fecdd8d91d024da7",
                "MacAddress": "02:42:ac:13:00:06",
                "IPv4Address": "172.19.0.6/16",
                "IPv6Address": ""
            },
            "5716e0e644230beef6b6cdf7945f3e8be908d7e9295eea5b1e5379495817c4d8": {
                "Name": "superset_app",
                "EndpointID": "bf22dab0714501cc003b1fa69334c871db6bade8816724779fca8eb81ad7089d",
                "MacAddress": "02:42:ac:13:00:04",
                "IPv4Address": "172.19.0.4/16",
                "IPv6Address": ""
            },
            "b09d2808853c54f66145ac43bfc38d4968d28d9870e2ce320982dd60968462d5": {
                "Name": "superset_node",
                "EndpointID": "70f00c6e0ebf54b7d3dfad1bb8e989bc9425c920593082362d8b282bcd913c5d",
                "MacAddress": "02:42:ac:13:00:07",
                "IPv4Address": "172.19.0.7/16",
                "IPv6Address": ""
            },
            "d08f8a2b090425904ea2bdc7a23b050a1327ccfe0e0b50360b2945ea39a07172": {
                "Name": "superset_cache",
                "EndpointID": "350fd18662e5c7c2a2d8a563c41513a62995dbe790dcbf4f08097f6395c720b1",
                "MacAddress": "02:42:ac:13:00:03",
                "IPv4Address": "172.19.0.3/16",
                "IPv6Address": ""
            },
            "e21469db533ad7a92b50c787a7aa026e939e4cf6d616e3e6bc895a64407c1eb7": {
                "Name": "vedasupersetmysql",
                "EndpointID": "d658c0224d070664f918644584460f93db573435c426c8d4246dcf03f993a434",
                "MacAddress": "02:42:ac:13:00:08",
                "IPv4Address": "172.19.0.8/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "default",
            "com.docker.compose.project": "incubator-superset",
            "com.docker.compose.version": "1.26.0"
        }
    }
]

我应该如何形成SQLAlchemy URI?我试过了mysql://user:password @ 8088:6603/database-name

How should I form the SQLAlchemy URI? I have tried mysql://user:password@8088:6603/database-name

但是当我输入此URI时,它显示连接错误.

But it shows connection error, when I enter this URI.

如果有任何相关文档,这也将有所帮助.

If there is any related documentation, that would also help.

推荐答案

该问题与超集或网络无关.您配置了正确的网络,但尚未在MySQL docker映像上启用 default-authentication-plugin .由于控制台上显示的错误是

The issue was not related to superset or network. You configured the right network but haven't enabled default-authentication-plugin on MySQL docker images. Due to this error showed on the console was

 Plugin caching_sha2_password could not be loaded:

要复制:

from sqlalchemy import create_engine
engine = create_engine('mysql://root:sample@172.19.0.5/mysql')
engine.connect()

错误日志:

   sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1045, 'Plugin caching_sha2_password could not be loaded: /usr/lib/x86_64-linux-gnu/mariadb19/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory')
    (Background on this error at: http://sqlalche.me/e/13/e3q8)

要解决此问题,请执行以下操作:

使用默认身份验证插件

docker run --detach --network="incubator-superset_default" --name=mysql --env="MYSQL_ROOT_PASSWORD=sample" --publish 3306:3306 mysql --default-authentication-plugin=mysql_native_password 

Superset已经拥有一个用户定义的网桥网络,因此您可以同时使用这两种格式

Superset already has a User-defined bridge network, so you can use both formats

mysql://root:sample@mysql/mysql
mysql://root:sample@172.19.0.5/mysql

这篇关于我在docker上安装了mysql和apache超集,并通过网桥网络连接,SQLAlchemy URI是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆