go-mysql:从go应用程序容器连接到mysql容器时,不支持身份验证插件 [英] go-mysql: authentication plugin not supported while connecting from go app container to mysql container

查看:111
本文介绍了go-mysql:从go应用程序容器连接到mysql容器时,不支持身份验证插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am porting my linux docker environment from my mac to my pc laptop. I have 2 docker images, one is a mysql:latest database image, the other is a go:alpine application server image.

在我的Mac上,我使用bash脚本将环境变量传递给应用服务器,以构成与mysql的数据库连接字符串.

On my mac, I use bash scripts to pass in environment variables to the app server to compose the database connection string to mysql.

连接字符串为:

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

当我在Mac上但未在PC上运行数据库连接时,数据库连接成功.

The database connection is successful when I run this on my mac, but not on my PC.

Windows 10上,我已经安装了UbuntuDocker for Windows.在bash中,我已经安装了docker客户端,并且能够通过设置DOCKER_HOST环境变量来使用docker cli连接到我的Windows Docker主机.

On Windows 10, I have installed Ubuntu and Docker for Windows. In bash, I've installed the docker client and I am able to use the docker cli to connect to my Windows Docker host by setting the DOCKER_HOST environment variable.

我创建了一个自定义docker网络,我通过--network标志将其传递给我的2个容器,以便他们可以互相看到,并且我已验证它们确实能够解析其容器名称.

I have created a custom docker network that I pass to my 2 containers via the --network flag so they can see each other and I have verified that they are indeed able to resolve their container names.

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

The connection string that my app server is using is exactly the same, but returns the following error:

this authentication plugin is not supported

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

The line in my go code returning this error is:

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

我想念什么?什么身份验证插件?

What am I missing? What authentication plugin?

这是我的PC上docker info的输出:

Here is the output of docker info on my PC:

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映像最近(最新")标记已从5.7更改为5.7(2018/04/20),其中有很多重大更改.使用"mysql:5.7"代替"mysql"应该可以解决您的问题.

MySQL image on docker hub changes "latest" tag from 5.7 to 8 recently (2018/04/20), which has lots of breaking changes. Using "mysql:5.7" instead of "mysql" should solve your problem.

这篇关于go-mysql:从go应用程序容器连接到mysql容器时,不支持身份验证插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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