1 Principle
Remote access to the database must pass through a firewall, and must have database access permissions, otherwise access is denied, then remote tools to access the database must consider two issues: how to enter the Linux system, whether the database allows access.
2 Test the connection
2 steps
2.1 Turn on the firewall
Firewall technology is a kind of organic combination of various software and hardware devices used for security management and screening to help computer networks build a relatively isolated protective barrier between their internal and external networks to protect user data and information security. technology.
2.1.1 Check the status of the firewall
命令:[root@localhost ~]# firewall-cmd --state
Check the ports opened by the firewall
命令:[root@localhost ~]# firewall-cmd --list-port
Check if a certain port is open
命令:[root@localhost ~]# firewall-cmd --query-port=3306/tcp
Open a certain port firewall
命令:[root@localhost ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
Close the firewall of a certain port
命令:[root@localhost ~]# firewall-cmd --zone=public --remove-port=3306/tcp --permanent
2.1.2 Turn off the firewall
Command: [root@localhost ~]# systemctl stop firewalld.service
command: [root@localhost ~]# systemctl start firewalld.service Turn on the firewall
command: [root@localhost ~]# systemctl reload firewalld.service restart the firewall
command: [root @localhost ~]# [root@localhost ~]# firewall-cmd --reload restart firewall
command: [root@localhost ~]# [root@localhost ~]# firewall-cmd --state
2.2.3 Change the default startup mode of the firewall
The firewall will be activated when the Linux system is booted by default, so we can set the default boot mode to not boot up automatically.
Command: [root@localhost ~]# systemctl disable firewalld.service
Command: [root@localhost ~]# systemctl enable firewalld.service starts up
2.2 Turn on access permissions
2.2.1 Start the database
命令:[root@localhost src]# systemctl start mariadb
命令:[root@localhost src]# mysql -u root -p
2.2.2 Open permissions
Change the localhost in the user table in the MySQL database to%
SQL:MariaDB [mysql]> update user set host="%" where host=“localhost”;
2.2.3 Refresh database permissions
Command: MariaDB [mysql]> flush privileges;