256815 (2) [Avatar] Offline
#1
Watched video and followed instructions to the letter - I think. When I attempt to view webpage I get an error:"Cannot connect to the database Error: The server requested authentication method unknown to the client". Is this only true for me?
Peter Fisher (8) [Avatar] Offline
#2
Hi,
Sorry to hear that you are having problems with connecting to the database.
Are you able give me further information about this?
- In which module/unit/video are experiencing the issue?
- Are you using the Docker images from https://hub.docker.com and if so which tag are you using?
- Are you using the code on git hub (https://github.com/pfwd/manning-docker-in-motion) and if so which tag are you using?
TejaswiniUL (2) [Avatar] Offline
#3
Connecting to a mysql running on a Docker container
I'm trying to run mysql server on a Docker (installed with Docker Toolbox for Mac) container and access it from my machine running OS X Yosemite. The documentation from the official repo does not explain how to connect from outside the docker host !!

I've created a container using the official repository as follows:

[color=green]$ docker pull mysql
$ docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest -p 3306:3306 
$ docker-machine ip default
192.168.99.100
$ docker inspect CONTAINER_ID[/color]


Then I get the ip address (172.17.0.1), but when I ping it I see time outs!!!
I tried to add port forward to the default machine:

VBoxManage controlvm "default" natpf1 "tcp-port3306,tcp,,3306,,3306";
But when connecting with Sequel pro (a mysql client) with root @192.168.99.100 on 3306, I have a connection failure.

What's the appropriate way to connect to the running mysql server?


Thanks & Regards
Tejaswini UL
Peter Fisher (8) [Avatar] Offline
#4
Hi Tejaswini,
To claify you have created a Docker MYSQL container and wish to connect to this via the host machine?
If this is the case then I would suspect that there is an issue with the network configuration between the container and the host.

The networking side of Docker isn't something that this course overly focuses on however I will have a think, run some tests here and get to you.
TejaswiniUL (2) [Avatar] Offline
#5
Thanks Peter
149376 (3) [Avatar] Offline
#6

Hi,

The reason for this issue is that the PHP mysqli connection method does not support the default login
method of MySQL 8.x. To get around this, add the following to the mysql Dockerfile (as the third line):

RUN echo default-authentication-plugin=mysql_native_password >> /etc/mysql/my.cnf

I assume it would also work to downgrade MySQL to 7.x, but downgrading is no fun smilie
Peter Fisher (8) [Avatar] Offline
#7
Hi all, For MYSQL you can use Docker tags to denote the MYSQL version.
EG:
$ docker pull mysql:5.7.23


Here is a list of all available MYSQL docker tags: https://hub.docker.com/r/library/mysql/tags/

So in Tejaswini UL case you could use this:
$ docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw  -p 3306:3306 -d mysql:5.7.23


- Remember that the latest tag doesn't always mean the latest version
477057 (1) [Avatar] Offline
#8
This was my exact issue. Just needed to specify FROM mysql:5.7.23 in the mysql Dockerfile.