Set up a MySQL server to answer ports and bind IP addresses
- The MySQL server listens to port 3306 By default and determines the firewall to open this port.
- Edit/ETC/MY.CNF Add the binding IP address.
bind-address=192.168.42.135
- Restart the MySQL server to view the listening status.
[Email protected] ~]$ NETSTAT-LNT
Active Internet connections (only servers)
Proto recv-q send-q Local address Foreign address state
TCP 0 0 192.168.42.135:3306 0.0.0.0:* LISTEN
Create user
CREATE USER IF not EXISTS ' ubuntu ' @ ' 192.168.42.136 ' identified by ' [email protected] ';
192.168.42.136
: For Client IP
ubuntu
: User Name
[email protected]
: Log In Password
This user only allows the client to log in with the IP address 192.168.42.136
, and if the user wants to log on to any client, it will 192.168.42.136
change to %
.
Install the MySQL client (in Ubuntu, for example)
- Apt Install mysql-client-x.x
- Log in using the following command
mysql -h 192.168.42.135 -u ubuntu -p
192.168.42.135
: The IP address of the MySQL server
MySQL client remote connection to MySQL server