my MySQL 8.0.31 database is running on port 33060 and this works well. But unfortunately, I cannot access the database from another server. When I check with
root:~# sudo lsof -i -P -n | grep 33060
docker-pr 1226664 root 4u IPv4 13558339 0t0 TCP 127.0.0.1:33060 (LISTEN)
I see that if listen on 127.0.0.1
but not on 0.0.0.0:33060
as expected. My config in my.cnf
looks like this:
[mysqld]
bind-address=0.0.0.0
skip-host-cache
skip-name-resolve
datadir=/var/lib/mysql
socket=/var/run/mysqld/mysqld.sock
secure-file-priv=/var/lib/mysql-files
user=mysql
pid-file=/var/run/mysqld/mysqld.pid
sql-mode=""
server-id=3333333
log_bin=mysql-bin
log_error=mysql-bin.err
binlog_do_db=demo
gtid_mode = ON
enforce-gtid-consistency = ON
ft_min_word_len=2
[client]
socket=/var/run/mysqld/mysqld.sock
!includedir /etc/mysql/conf.d/
I already try to remove bind-address
or set it to different values like *
or the IP address from the accessing server, but everything seems to be ignored.
I have another server with the same configuration and there it works fine. Why is bind-address
is being ignored and how can I force to set the 0.0.0.0
?
I think you configured the database network to listen on 0.0.0.0
but the docker container is listening on 127.0.0.1
(default).
If that’s the case you should add the following flag to your docker run
command
-p 33060:33060
After that when you run docker ps
you should see 0.0.0.0:33060->33060/tcp
on your container. Also the lsof
should verify this as well.
Meanwhile I was able to find a generic solution: simply remove the line {"ip":"127.0.0.1"}
from /etc/docker/daemon.json
fixes that issue.
so that it can accept the connection from every ip, and a specific one
How are you trying to connect from the remote machine?
@JRichardsz at the moment I’m just doing a
nc -zv IPADDRESS 33060
and it failsAre you running mysql with docker? What was your sentence?