0

I have setup a MariaDB ColumnStore Database as described in the MariaDB ColumnStore Quick Start guide. The guide is missing some steps so these are the exact steps I took:

docker run -d -p 3306:3306 --name mcs_container mariadb/columnstore

docker exec -it mcs_container bash

yum install git wget

git clone https://github.com/mariadb-developers/mariadb-columnstore-quickstart.git

./get_flight_data.sh

mariadb

        CREATE USER 'user1'@'%' IDENTIFIED BY '<PASSWORD>';

        GRANT ALL ON travel.* TO 'user1'@'%';

Exit mariadb client

./create_and_load.sh 127.0.0.1 3306 user1 <PASSWORD>

I can query the DB from within the container. Now, I want to connect to the DB from my local Windows 11 machine through TCP. But every time I try to connect to it using a local MySQL client I get the following error:

C:\Program Files\MariaDB 10.9\bin>mariadb --host 172.17.0.2  --port 3306 --user app_user -p
Enter password: ********
ERROR 2002 (HY000): Can't connect to server on '172.17.0.2' (10060)

Edit: I am using Docker Containers IP Address 172.17.0.2 in the above request since I am trying to connect to the server/DB that is inside the container. I found the IP address through the following command:

docker inspect -f "{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}" mcs_container

For further clarity, the diagram below illustrates the setup and problem, the connection (middle arrow) is what is failing at the moment. enter image description here

Edit End

I did some trial and error through the research I found online but I have reached an impasse. I don't know what I am missing. Here are a few things I have tried:

  1. Followed this video as well as section 2.3 of this article detailing how to connect to a containerized MariaDB/MySQL server. No luck.
  2. I also looked into bind addresses as mentioned here. But as mentioned in this more recently answered question, bind addresses may not be the problem. And I don't exactly understand what I am messing with here. So I left it alone for now.
  3. Last possibility I could think of is that it could be a firewall issue, as mentioned here. I use Kaspersky Internet Security - I tried disabling the firewall but again that made no difference.

I am new to docker, sorry if I have overlooked something small and obvious. Any help will be really appreciated. Thank you.

12
  • I'm also still new to containers, but I can see that you have created the container and mapped port 3306 on localhost to 3306 inside the container. So, I think you should be trying to connect the mariadb client to localhost:3306 (or maybe 127.0.0.1:3306) rather than that other IP address?
    – dbdemon
    Commented Oct 21, 2022 at 15:44
  • How did you obtain the IP address 172.17.0.2 and why do you think it's the one to connect to?
    – mustaccio
    Commented Oct 21, 2022 at 16:45
  • @dbdemon 172.17.0.2 is docker IP address. In my understanding, that is basically telling the MySQL client I want to connect to the MySQL DB that is inside the Docker container. If I specify localhost instead, it would try to connect to the DB on my local machine, and it would also fail since the user doesn't exist in the local machine.
    – Malvi Bid
    Commented Oct 21, 2022 at 16:45
  • @mustaccio I have edited my question clarify how I obtained the IP address 172.17.0.2. And the reason I am using it is because that is the IP address of the docker container. This is telling the MySQL client on my local machine to connect to the MySQL/MariaDB server that is inside the container.
    – Malvi Bid
    Commented Oct 21, 2022 at 17:03
  • If you have a MySQL or MariaDB running in the computer, it is already using 3306. In that case "-p 3306:3306" will conflict. Map to another port number.
    – Rick James
    Commented Oct 21, 2022 at 17:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.