Today, I tried the MySQL connection between two computers. I had a whim today, but the whole process took a long time.
Test environment:
PC1: win10
Install mysql5 seven point three one
IP: 192.168.1.202
PC2: win10
Install mysql5 seven point three one
IP: 192.168.1.203
1. First connection test
1.1 PC1 connection PC2
1.2 PC2 connection PC1
1.3 problem solving
After finding the problem on the Internet, I found that the port was blocked because the firewall blocked it. So I modified it according to the prompt. After that, the Ping was passed and half of it was completed.
The solution is to turn on the firewall of the computerFile and print sharing
Provide a port for Ping.
Specific steps
Control panel – > system and security – > Windows Defender Firewall – > Advanced Settings – > inbound rules – > file and print sharing (echo request – icmpv4 in) – > right click – > enable rules
reference material
CSDN: summary of the problem that two computers cannot Ping under the LAN
System city: what if the win10 pure version and win10 professional version computers fail to Ping
2. Database users
Because the MySQL databases of the two computers access each other, the user’s host needs to be changed to the specified IP or any IP.
Here, take PC1 connecting to PC2 as an example. Create a new user JUKI in the MySQL database of PC2. The host can be PC1’s IP or%,% represents any IP, and all hosts can access it. This is obviously not very safe. It is only for testing and trial.
--Create user JUKI
insert into mysql.user(host,user,authentication_string,ssl_cipher,x509_issuer,x509_subject) values('%', 'juki', password('juki233'), '','','');
--Make new users effective
flush privileges;
--View user information
select user,host from mysql.user;
reference material
Baidu experience: how to solve the error that MySQL does not allow remote connection
3. Connect to the database
As soon as the connection problem came out again, it showed that the remote server could not be connected. After that, I found a lot of information, most of which are MySQL servers based on Linux. The solution is to comment it outmysql.cnf
In the filebind-address=127.0.0.1
This line, but it doesn’t solve my problem
Finally, I found an effective solution. My simple understanding of this solution is to open another port for MySQL:Blog Garden: remote connection to MySQL under Windows, I followed the steps and finally finished it, nice~~~