Here's how it's implemented:
1, first check the MySQL server firewall, if the external network to 3306 port connection, then release the limit
Executed in Linux server
Iptables-l can view the current firewall rules
Iptables-f can empty all firewall rules
2. Ensure that the MySQL listening address is 0.0.0.0
The listening address is 0.0.0.0, which means that MySQL allows all IP addresses to connect, which is the basis for allowing remote connections
The listening address is 127.0.0.1, which means that MySQL only allows local connections to the server, and the extranet is not connected.
How do you know what MySQL's listening address is?
Perform the following command on the Linux server to view: Netstat-nutlp|grep MySQL
Windows Server executes the following command in CMD to view netstat-ano|findstr MySQL
What if the listening address is not 0.0.0.0?
Because MySQL is listening 0.0.0.0 by default, if the view is not listening, it is definitely the bind-address parameter in the configuration file,
You need to modify the bind-address parameter in the MySQL configuration file to change the bind-address=127.0.0.1 to bind-address=0.0.0.0
Once saved, restarting the MySQL service will take effect.
Take the Linux system as an example:
3. Add a remote connection to MySQL account
This step is necessary to operate, MySQL itself users can only connect to the database on this computer, external network connection, you need to add remote users and authorization.
Add remote connection user in MySQL command line mode, or execute SQL statement in phpMyAdmin
> Grant All on * * to [e-mail protected] '% ' identified by ' 123456 ';
> Flush Privileges;
Command explanation:
* * The first * indicates the library, the second * represents a table; * * Full table Authorization for all databases, so.ok means only the OK table in the so library is authorized
Root indicates to which user to authorize, this user can be the existing user, can also be non-existent
'% ' means the IP address that allows remote connections,% means all IP connections are allowed
Allow only one IP remote connection, can be written as ' 123.123.123.123 '
Only allow 123.123.123.* this network segment remote connection, can be written as ' 123.123.123.% ' 123456 ' is to set the authorized user's connection password
Flush privileges; Represents an immediate refresh of the permissions table for the added user to take effect
With all three steps set up, you can try to connect to MySQL remotely again.
How to allow an extranet to connect to a MySQL database