How to Activate MySQL for Multiple Devices How to Activate MySQL for Multiple Devices This tutorial will guide you through the steps to allow multiple devices to access your MySQL server over a network. Prerequisites MySQL server installed on your host machineAccess to the MySQL root user or an adm
How to Activate MySQL for Multiple Devices
This tutorial will guide you through the steps to allow multiple devices to access your MySQL server over a network.
Prerequisites
- MySQL server installed on your host machine
- Access to the MySQL root user or an admin account
- Basic knowledge of networking
Step 1: Configure MySQL to Listen on All IP Addresses
- Open the MySQL configuration file (
my.cnf
ormy.ini
).- On Windows: Usually located at
C:\ProgramData\MySQL\MySQL Server X.X\my.ini
- On Linux: Usually at
/etc/mysql/my.cnf
or/etc/my.cnf
or/etc/mysql/mysql.conf.d/mysqld.cnf
- On Windows: Usually located at
- Find the line starting with
bind-address
.bind-address = 127.0.0.1 mysqlx-bind-address = 127.0.0.1
- Change it to:
This allows MySQL to accept connections from any IP address.bind-address = 0.0.0.0 mysqlx-bind-address = 0.0.0.0
- Save the file and restart the MySQL service.
- Windows:
net stop mysql net start mysql
- Linux:
sudo systemctl restart mysql
- Windows:
Step 2: Allow Remote Connections in the Firewall
- Open port 3306 (default MySQL port) in your firewall settings.
- Windows: Use Windows Defender Firewall to allow inbound connections on port 3306.
- Linux:
sudo ufw allow 3306/tcp
Step 3: Create a MySQL User for Remote Access
⚠️ Important: At this point MySQL will accept connections from anywhere. If your server is exposed to the internet, secure it:
- Log in to MySQL as root:
mysql -u root -p
- Create a new user or update an existing user to allow access from a specific IP or any IP (
%
):CREATE USER 'username'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES;
Replace
username
andpassword
with your desired credentials.
Step 4: Connect from Another Device
On the client device, use the following command to connect:
mysql -h <server-ip-address> -u username -p
Replace <server-ip-address>
with the IP address of your MySQL server.
Security Tips
- Only allow trusted IPs if possible (replace
%
with a specific IP or subnet). - Use strong passwords for all MySQL users.
- Consider enabling SSL for encrypted connections.
You have now enabled MySQL access for multiple devices on your network!