MySQL Bind Address in Ubuntu – How we set it right
Oops!! Facing trouble setting the MySQL bind-address in Ubuntu? We can help you.
Bind-address tells on which networks MySQL should listen for connections.
At Bobcares, we often get requests to fix MySQL errors, as a part of our Server Management Services.
Today, let’s see how our Support Engineers set the proper bind address for our customers.
What is this MySQL bind-address in Ubuntu?
Firstly, let’s see the details of the MySQL bind address.
It is the value that tells the IP address on which MySQL listens for the connections. There are mainly three basic ways for configuring bind-address, that make MySQL server available to:
- no network
- all network
- And, to a specific network
1. To no network
Firstly, binding to no network means MySQL listens to connections only from the localhost. Here, the bind-address takes a value of 127.0.0.1, the loopback IP address. Here, MySQL can be accessed only by applications running on the same host.
From our experience in managing database servers, we see most web hosting servers use this way. It can easily accommodate all the applications that use local databases. Thus, a WordPress user can easily connect to his database.
2. To all network
Whereas MySQL listening to all network means, in the bind-address configuration we specify IP as 0.0.0.0. Here, MySQL listens from all networks. The exact value appears as
bind-address = 0.0.0.0
Here, the server accepts connections on all IPv4 addresses on the server. Furthermore, to permit both IPv4 and IPv6 connections on all server interfaces, we set the MySQL bind address. The Wildcard address values here means one of the following string values: ‘*’, ‘::’ and ‘0.0.0.0’.
This is the default configuration for bind-address. But, this lacks security. So, we usually configure the server firewall in a way to allow MySQL connections from specific IP addresses only.
To allow incoming MySQL connections from a specific IP address or subnet, we use the command,
ufw allow from IP/subnet to any port 3306
Here, we replace the IP/subnet using the required IP address or the entire subnet that is to be allowed.
3. Listen to a specific network
Here, MySQL is allowed to listen only to a specific network interface. The value, in this case, will be
In a shared host, we always suggest using the IP of the server as the bind-address. Again, MySQL Server 8.0.13 allows configuring the address listening to more than one specific interface.
How do we fix the MySQL bind address error?
While dealing with MySQL, we may encounter some problems related to bind-address also. Today, let’s discuss some scenarios where our customers faced trouble with this bind-address.
Recently, one of our customers approached us with MySQL bind address problem in his Digital Ocean droplet. After creating a new Ubuntu droplet using the snapshot, he was unable to log into MySQL using the login credentials.
So, our Engineers checked in detail and found that the MySQL service was down. So, we checked the error log and found the following:
Hence, our Engineers checked whether the bind-address was given properly. We found that the customer created the new droplet from a snapshot, but the IP address in configuration was of previous servers.
So, we followed the steps below for changing the IP.
Firstly, we opened the MySQL configuration file at /etc/mysql/my.cnf.
Then, added the new droplet’s IP in bind-address as shown:
Then restarted the MySQL service using the command below:
service mysql restart
This fixed the problem and customer successfully accessed MySQL.
Instead of giving the server’s IP, we can also give the loop-back address i.e. 127.0.0.1.
[Trouble with MySQL bind-address setting? We are here to help you.]
In short, we may face problems like MySQL down due to incorrect bind-address. Today, we discussed in detail on how our Support Engineers fix MySQL bind-address error in the Ubuntu server for our customers.