Because of the filtering function in the firewall, it is forbidden to enter the outside data message, can set
Iptables-i input-p tcp-d 192.168.18.9--dport 3306-j ACCEPT
Iptables-i output-p tcp-s 192.168.18.9--sport 3306-j ACCEPT
Note that this rule must be placed on top of the top-I INPUT is appended to the top by default, so that it can be blocked from the beginning otherwise. For security best set to port. The TCP setting is passed because the remote connection uses SSH, based on TCP.
So you can log on to MySQL remotely.
Of course, first of all, you have this user's permission in MySQL.
The ' root ' @ ' 192.168.%.% ' user needs to exist and have permission to log in as root from the 192.168.%.% network.
You can use statements directly
MariaDB [(None)]> grant all privileges on * * to ' root ' @ ' 192.168.%.% ' identified by ' 150370992390KD ';
So you can connect MySQL from a distance.
This article is from the "Gusu City" blog, make sure to keep this source http://ji123.blog.51cto.com/11333309/1957514
How to set up a firewall to enable MySQL to connect remotely