MariaDB Docker cannot connect using local domain as host - mysql

I have an issue with my dockerized MariaDB. It happens when I try to connect to MariaDB.
Example with PhpMyAdmin: If I put MariaDB docker server's IP & port in the PHPMyAdmin config file (see picture), PhpMyAdmin can connect without any issue. But if I put the server hostname and the port, it doesn't connect. MariaDB doesn't accept the hostname. One of the problems I have is that the server change the IP, so it's an issue if I am not using the hostname. I checked that etc/mysql/my.cnf has #Bind 127.0.0.0 in docker container with #.
Also, the hostname works well in the browser (windows or linux).
Does anyone know how to fix this?
EDIT
I am also attaching the container info from Portainer.
Thanks

Related

None of created networks in Docker have access to the internet and can't connect to a remote database server

I am facing a strange problem with my docker. I had to reinstall it as in the following link: Docker Installation on Ubuntu 18.04
I did this installation before, so everything worked out fine. Then I created the network like this:
docker network create --subnet=172.18.0.0/16 mynet123
And finally built my container. But it can't connect to a database remote server. It gives the following error:
So I checked my internet connection from inside docker container and it turned out that I don't have it. So I guess that's the root of the problem. I tried reinstalling docker, changing docker network by specifying other subnet, followed this instruction
Stackoverflow solution
But still no result. Does anybody have an idea how I can sort this out?
By the way, this is how I connect to MySQL using python:
dbconn = mysql.connector.connect(host=config["mysql"]["host"], database=config["mysql"]["database"], user=config["mysql"]["user"], password=config["mysql"]["password"])
cursor = dbconn.cursor()
And here is my config:
[mysql]
host = X.X.X.X.
database = database_name
user = root
password = password
*X.X.X.X here is an IP address of the remote host
P.S. I can connect to the remote database from my local machine, containers can connect to the database server via default network. All user permissions in my database are given.

Couldn't connect linux mysql server from other server

I tried everything which I found on google but couldn't connect linux mysql server from other server, Server where Mysql is located is Linux OS and from where I want to connect that is ubuntu, What can I do?
I already grant all privileges to user, bind-ip-address, and comment localhost etc. Is there any sqlserver's internal configurations?
Did you check ssh connectivity between two servers? if it doesn't works configure sshd properly and if ssh connectivity works fine then,The Target server's internal firewall might be blocking remote mysql connections.
After a long R&D, when nothing help me, I think about port number, and that was silly mistake, actually I check available port on AWS for that instance from I want to connect and found I forgot to open 3306 (default MySQL port). I just add this and everything became perfect.

Connecting to localhost mysql server from inside docker container on macOS

How can I connect to localhost mysql server from a docker container on macOS ?
One way to do it using --add-host but that requires me to pass some name like "myhost".
Is there any way in macOS so that references to localhost from inside docker container actually refer to docker host ?
On MacOS docker provide special DNS name docker.for.mac.localhost which will resolve to the internal IP address used by the host.
use host.docker.internal
to connect to the host running the Docker.
this works From docker version 18.03 onwards only and This is for development purposes and will not work in a production environment outside of Docker Desktop for Mac.
( refer the page https://docs.docker.com/docker-for-mac/networking/ for more info )
sample connection string for oracle, jdbc:oracle:thin:#host.docker.internal:1521/orcl
From inside of a Docker container, how do I connect to the localhost of the machine?
You should be able to connect to MySql running on host machine using host machine actual IP address. In MacOS, try to find your ip by command ifconfig. Mostly using IP assigned to en0 i.e. your ethernet interface should work. Just call that IP from within your container.
*localhost or 127.0.0.1 or 0.0.0.0 doesnt call host machine as they are local to container itself.

Unable to connect to Mysql Database hosted on VM Windows Server using 3306 port

I have been trying to find a solution but could not fixed my problem. MySQL database is hosted on a remote server inside Virtual Machine, I have only rights to the Virtal Machne, I have tried following solutions but still my problem is not fixed: Added 3306 port for MYSQL in firewall settings, disabled the firewall, remove bind-address from my.ini files on my local machine as well as server and grant the priviliges from mysql client tool but no success. Can anyone help me out with this problem please?

problems connecting to port 3306 mysql workbench with XAMPP

I'm trying to learn the apache / mysql / php stack bundled with XAMPP. I can't connect to the MySQL server using the MySQL workbench:
Your connection attempt failed for user 'root' from your host to server at localhost:3306: Can't connect to MySQL server on '127.0.0.1' (61)
Thinking it's a port problem, I check the port directly in Terminal with the command telnet 3306:
telnet: connect to address 127.0.0.1: Connection refused
Obviously the problem isn't with the Workbench, but something to do with the port connection itself.
I'm using:
OS 10.8 Mountain Lion
XAMPP 1.7.3
MySQL workbench 5.2.47
Sorry all, I'm posting my own question and answer. I had this problem and it nearly destroyed me because I could not find the correct answer anywhere on the interwebz. I finally overcame it, and wanted to post my findings in case it helps another befuddled traveler.
It turns out when you install XAMPP and choose to run the security routines, it automatically turns on a setting in the MySQL preferences to block connections on port 3306 from localhost. To fix this, open my.cnf in the xampp folder xamppfiles/etc. Look for the setting "skip-networking" which tells mySQL to block the port 3306. Comment this out by adding a pound sign so it is "#skip-networking". Now, the telnet command should work, and you should be able to use the Workbench.
Hope this is helpful for somebody!If it fixes your problem, give me a shout at #mrcheeks3185.
I faced same problem but I solved it.
I changed the MySQL workbench port to 3307 in the file below
C:\ProgramData\MySQL\MySQL Server 5.7\my.ini
and keep the default port 3306 for XAMPP
for mac you should create only a user with password and grant access(in my case a I use root with password) and turn on ip address and use that address to connect with a client like navcat or workbench I use XAMPP 7.3
ip address network given by XAMPP
connection config in navcat
test connection
I found that file after mount the image disk created for xampp, there you can find new_disc_mounted/etc/my.cnf
If you do not have my.cnf you can first go to xampp->mysql->bin->my.ini, copy
the contents of the file, next create my.cnf (in the bin folder) and paste the content to the file you just created.
This works for me. I had the same problem. Now I can use both Xampp and Workbench on one PC.
There is an issue: when you start workbench you get some warning that some features may not work properly since database is not fully compatible.
If changing ports won't work. What I did, I just make sure both XAMPP and MySQL Workbench don't start the server at the same time. Just go to MySQL Workbench, Select Server > Startup/Shutdown > Shutdown.
its due to different version of xampp, open log file and check last status of mysql there is showing error find it or remark/change it
Actually XAMPP and MySQL workBench might be using same port an are conflicting "3306" in so you are getting that error
Please try changing the workBench's default port number to other number and try again