草庐IT

mysql - 去-mysql : authentication plugin not supported while connecting from go app container to mysql container

coder 2023-06-28 原文

我正在将我的 linux docker 环境从我的 mac 移植到我的笔记本电脑上。我有 2 个 docker 镜像,一个是 mysql:latest 数据库镜像,另一个是 go:alpine 应用服务器镜像。

在我的 mac 上,我使用 bash 脚本将环境变量传递给应用服务器,以将数据库连接字符串组合到 mysql。

连接字符串是:

root:password@tcp(mysql_host:3306)/dbname

当我在我的 mac 上运行它时,数据库连接成功,但在我的 PC 上却没有。

Windows 10 上,我安装了 UbuntuWindows 版 Docker。在 bash 中,我安装了 docker 客户端,我可以通过设置 DOCKER_HOST 环境变量使用 docker cli 连接到我的 Windows Docker 主机。

我创建了一个自定义 docker 网络,我通过 --network 标志传递给我的 2 个容器,这样它们就可以看到彼此,并且我已经验证它们确实能够解析它们的容器名称.

我的应用服务器使用的连接字符串完全相同,但返回以下错误:

this authentication plugin is not supported

我的 go 代码中返回此错误的行是:

db, err = sql.Open("mysql", dbConnStr)

我错过了什么?什么认证插件?

这是 docker info 在我的电脑上的输出:

Containers: 1
 Running: 0
 Paused: 0
 Stopped: 1
Images: 27
Server Version: 18.04.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.87-linuxkit-aufs
Operating System: Docker for Windows
OSType: linux
Architecture: x86_64
CPUs: 6
Total Memory: 3.837GiB
Name: linuxkit-00155d016401
ID: JXLB:YHLO:J6XO:H66P:X7LQ:RF2I:Z3AC:FPLY:OCLQ:DSYU:H4CR:W2DD
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 19
 Goroutines: 36
 System Time: 2018-04-23T06:06:31.2274774Z
 EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

最佳答案

docker hub 上的 MySQL 镜像最近(2018/04/20)将“最新”标签从 5.7 更改为 8,其中有很多重大更改。使用“mysql:5.7”而不是“mysql”应该可以解决您的问题。

关于mysql - 去-mysql : authentication plugin not supported while connecting from go app container to mysql container,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49974372/

有关mysql - 去-mysql : authentication plugin not supported while connecting from go app container to mysql container的更多相关文章

随机推荐