I have create a mariaDB database in a server. How to change bind-address such that pc from the same network is allowed to connect to this db?
To allow other PCs on the same network to connect to your MariaDB database, you need to modify the bind-address
setting in the MariaDB configuration file. Here’s how you can do it:
Locate the Configuration File:
/etc/mysql/my.cnf
or /etc/my.cnf
. You might also find it in /etc/mysql/mariadb.conf.d/50-server.cnf
on some systems.Edit the Configuration File:
nano
or vi
:
sudo nano /etc/mysql/my.cnf
or
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
Modify the bind-address
:
bind-address
. It might look like this:
bind-address = 127.0.0.1
bind-address
to 0.0.0.0
to allow connections from any IP address on the network:
bind-address = 0.0.0.0
Save and Exit:
nano
, you can do this by pressing CTRL + X
, then Y
to confirm changes, and Enter
to exit.Restart MariaDB Service:
sudo systemctl restart mariadb
mysql
instead of mariadb
:
sudo systemctl restart mysql
Configure Firewall (if necessary):
ufw
or iptables
to configure this. For example, with ufw
:
sudo ufw allow 3306/tcp
Grant Access to Users:
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
'username'
and 'password'
with the actual username and password.By following these steps, you should be able to allow other PCs on the same network to connect to your MariaDB database.