Following the guide to create a mysql NDB cluster on https://hub.docker.com/r/mysql/mysql-cluster/ after initializing docker server exposing 3306 and 33060 I'm still unable to connect it using MySQL Workbench but I'm able to access it through CLI. Workbench throws an error saying as if there wasn't a database to be connected.
docker run -d --net=cluster --name=mysql1 --ip=192.168.0.10 -e MYSQL_RANDOM_ROOT_PASSWORD=true -p 3306:3306 -p 33060:33060 mysql/mysql-cluster mysqld
Besides trying to login with root I've also created a new user to try to login with the same outcome.
Related
I have created a MySQL image on my Windows 10 using the default settings from Docker.
I started the container using this command:
docker run --name local-mysql --network="host" -p 3306:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d <your-docker-Image>
I used the --network parameter in the hope that I could connect to the container from my host computer.
Then I ran this command to connect to the container from the MySQL shell
docker exec -it mysql bash -l
I was able to connect using this
mysql -h localhost -P 3306 --protocol=tcp -u root -p
Using Delphi and setting FireDac to use DriverId MySQL, I specified host as localhost, port 3306, user as root and the password.
But I get this connection error
[FireDAC][Phys][MySQL] Cannot connect to MySQL server on 'localhost:3306' (10061)
I have tried using 127.0.0.1 and 0.0.0.0 without success and with the same error.
I would appreciate it if anyone has tried it with Delphi FireDac to connect to a MySQL container hosted on the same computer.
Thank you in advance.
I was able to solve the issue by using this command to run the image
docker run --name local-mysql -p 127.0.0.1:3307:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d <your-docker-Image>
I used a different host port (3307) to map to the default 3306
I was able to test it using the bash first
mysql -h 127.0.0.1 -P 3306 -u root -p
And in Delphi FireDac, I used the following to connect
Host=127.0.0.1
Port=3307
User_Name=root
Password=my-secret-pw
And all is good. Hope this helps someone who is trying to the same.
I have created a MySQL deployment in kubernetes and exposed it as nodes-port.
What I can do:
Access it from inside the cluster using
kubectl run -it --rm --image=mysql:5.6 --restart=Never mysql-client -- mysql -h mysql -ppassword
What I want to do:
Access the MySQL server from outside the cluster(like accessing a normal MySQL server).
Kubernetes v1.13 in DigitalOcean Cloud.
Guide me, please.
You can access it by mysql -u {username} -p {password} -h {any kubernetes worker ip} -P {nodePort}. After you start mysql container and expose it ad node port through a service.
You need to specify the MYSQL_ROOT_PASSWORD while bringing up the pod. How were you able to bring it up in Docker without it?
I'm trying to start Vault docker container with mysql storage using this command:
docker run --cap-add=IPC_LOCK -e 'VAULT_LOCAL_CONFIG={"storage": {"mysql": {"username":"root", "password":"hello", "database":"vault", "address":"127.0.0.1:3306"}}, "listener": {"tcp":{"address":"127.0.0.1:8200", "tls_disable":"1"}}, "default_lease_ttl": "168h", "max_lease_ttl": "720h"}' -e VAULT_SKIP_VERIFY=true vault server
This is the error I'm getting:
Error initializing storage of type mysql: failed to check mysql schema
exist: dial tcp 127.0.0.1:3306: connect: connection refused
I can connect to mysql using the username and password I am supplying to the previous command.
I also made sure that the mysql is running on the 3306 port
[root#jwahba]# netstat -tlpn | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 39552/mysqld
I checked out the vault official document (here) but it's not obvious what is wrong in my configuration. Any suggestions please ?
You are trying to connect to a db on localhost from a Docker container, but they are on different network stacks. Use --net="host" in your docker run command; 127.0.0.1 in your docker container will now point to your docker host.
Source: From inside of a Docker container, how do I connect to the localhost of the machine?
I installed docker, got the most popular box with proxySQL.
docker run -d -p 6032:6032 --name proxysql prima/proxysql:latest
then I tried to connect to it from my local mysql like so:
mysql -u admin -padmin -h 127.0.0.1 -P6032
and I'm getting this error:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0 "Internal error/check (Not system error)"
I tried this trick with twindb/proxysql:latest and prima/proxysql:latest docker images and the result was the same :(
You cannot connect to proxysql from outside the container in default config. bash into the proxysql container and then execute
mysql -u admin -p<password-here> -h 127.0.0.1 -P 6032 --prompt='proxysql>'
default password will be the admin
You need to map 6033 instead of 6032
docker run -d 6033:6033 --name proxysql prima/proxysql:latest
And then run below
mysql -u admin -padmin -h 127.0.0.1 -P6033
Inside the container mysql listens on 127.0.0.1:6032 and for outside connections it listens on 0.0.0.0:6033. So you need to use 6033 for connections from outside the container
I created my container like this:
$ docker run -d -p 33060:3306 myimage
Then I try connect from host to mysql server in container:
$ mysql -uroot -proot -P 33060
I got this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
It odd because in Navicat only I changed the port and work fine:
But If I have the IP of the container:
$ docker inspect --format '{{ .NetworkSettings.IPAddress }}' mycontainer
172.17.0.55
Then I can connect to mysql server successfully:
$ mysql -uroot -proot -h 172.17.0.55
But it is a tedious task have to check the ip each time I create a new container to connect to mysql. There any settings I can do to make this task simpler?
This is not a Docker issue. By default the mysql command-line client will connect to a local (Unix) socket instead of a network one, even if you specify -P.
This behavior is described in the documentation:
On Unix, MySQL programs treat the host name localhost specially, in a way that is likely different from what you expect compared to other network-based programs. For connections to localhost, MySQL programs attempt to connect to the local server by using a Unix socket file. This occurs even if a --port or -P option is given
You have to pass the -hlocalhost option, or you can set your connection defaults in /etc/mysql/my.cnf