Background
I'm setting up a MySQL server. Its configuration file (my.cnf) does not have the bind_address
option. As I understand from its documentation, its value defaults to *
, which should make the server listen on all IPv4 or IPv6 addresses.
Problem
When I start the MySQL server, I expect it to listen to IPv4. Instead, it listens only to IPv6 as I've checked below.
$ netstat -nlt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp6 0 0 :::33060 :::* LISTEN
tcp6 0 0 :::3306 :::* LISTEN
# -- snip --
Why is this happening? And how can I let the MySQL server listen to IPv4 address?
What I have checked so far:
- I made sure that there are no other configuration file that unintentionally overrides the
bind_address
. When I querySELECT @@bind_address
, it correctly shows*
as intended. - I confirm that IPv4 networking is configured on my system. Running
ip addr show
shows thateth0
is assigned an IPv4 address. In fact, I don't think my system is configured for IPv6, as I don't see anyinet
with IPv6. - When I explicitly set
bind_address=0.0.0.0
in my.cnf and then restart the server, the server still listens to IPv6 address, showing the samenetstat
output above. - There are no other MySQL server instances running on my system.
Environment
- MySQL server: v8.0.36
- OS: CentOS 7
mysql -u root -p -h 127.0.0.1
, I'm able connect. Is that what you mean?sql-user
and setting the-h
option equal to the hostname of the MySQL server, I'm unable to connect. The network properly configured, and the MySQL user account, credentials and grants forsql-user
are also properly configured.ping <self ipv4>
, it shows 100% transmitted. Is that how I should check? Sorry, I'm new to network-related stuff.