I have create a database in one's server. How to change bind-address such that connection from the same network is allow?
To allow connections from the same network to your database server, you need to modify the bind-address
setting in the database server's configuration file. The exact steps depend on the database system you are using. Here, I'll provide instructions for MySQL/MariaDB and PostgreSQL, as they are commonly used databases.
Locate the Configuration File:
my.cnf
or my.ini
. It is typically located in /etc/mysql/
or /etc/
on Linux systems, and in the MySQL installation directory on Windows.Edit the Configuration File:
nano
on Linux:
sudo nano /etc/mysql/my.cnf
bind-address
directive. It might look something like this:
bind-address = 127.0.0.1
bind-address
to the IP address of the server on the local network, or use 0.0.0.0
to allow connections from any IP address:
bind-address = 0.0.0.0
Restart the MySQL/MariaDB Service:
sudo systemctl restart mysql
sudo systemctl restart mariadb
Locate the Configuration File:
postgresql.conf
. It is typically located in /etc/postgresql/[version]/main/
on Debian-based systems or /var/lib/pgsql/[version]/data/
on Red Hat-based systems.Edit the Configuration File:
sudo nano /etc/postgresql/[version]/main/postgresql.conf
listen_addresses
directive. It might look something like this:
listen_addresses = 'localhost'
listen_addresses
to the IP address of the server on the local network, or use '*'
to allow connections from any IP address:
listen_addresses = '*'
Edit the pg_hba.conf
File:
pg_hba.conf
file to allow connections from the desired IP range. This file is usually in the same directory as postgresql.conf
.192.168.1.0/24
subnet:
host all all 192.168.1.0/24 md5
Restart the PostgreSQL Service:
sudo systemctl restart postgresql
By following these steps, you should be able to configure your database server to accept connections from other machines on the same network.