duai0935 2018-04-23 06:04
浏览 119

go-mysql:从go应用程序容器连接到mysql容器时,不支持身份验证插件

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.

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

The connection string is:

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

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

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.

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

The line in my go code returning this error is:

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

What am I missing? What authentication plugin?

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
  • 写回答

1条回答 默认 最新

  • douzhan1994 2018-04-23 08:33
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器