Enable remote access rights for mysql By default, MySQL users do not have remote access permissions, so when the program and the database are not on the same server, we need to enable remote access permissions for MySQL. There are two mainstream methods, the table modification method and the authorization method. Relatively speaking, the table modification method is easier, and I personally prefer this method. Therefore, I will only post the table modification method here. 1. Log in to MySQL mysql -u root -p 2. Modify the user table of the MySQL database and change the host item from localhost to %. %This means that any host is allowed to access. If only a certain IP is allowed to access, you can change it to the corresponding IP. For example, you can change localhost to 192.168.1.123, which means that only the IP 192.168.1.123 in the local area network is allowed to remotely access MySQL. mysql> use mysql; mysql> update user set host = '%' where user = 'root'; mysql> select host, user from user; mysql> flush privileges; Open port 3306 on the firewall 1. Open the firewall configuration file vi /etc/sysconfig/iptables 2. Add the following line -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT 3. Restart the firewall service iptables restart Note: The statement to open port 3306 must be placed before icmp-host-prohibited Attachment: Personal configuration # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -i eth0 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT -A FORWARD -p icmp -j ACCEPT -A FORWARD -i lo -j ACCEPT -A FORWARD -i eth0 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: JavaScript implementation of drop-down list
>>: foreman ubuntu16 quick installation
Table of contents Problems encountered during dev...
Table of contents 1. Installation 2. Import in ma...
Referring to the online information, I used cmake...
MySQL 8.0 for Windows v8.0.11 official free versi...
Anyone in need can refer to it. If you have tried...
Dig Introduction: Dig is a tool that queries DNS ...
border-radius:10px; /* All corners are rounded wi...
1. Time difference functions (TIMESTAMPDIFF, DATE...
Preface Every time you use Docker to start a Hado...
1. What is mycat A completely open source large d...
This article shares the specific code for WeChat ...
CSS Styles html,body{ width: 100%; height: 100%; ...
Table of contents specification a. The page file ...
Some of you may have heard that the order of trav...
1. Wireless Run PowerShell and enter the command:...