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
1. Windows Server 2019 Installation Install Windo...
Preface In order to meet the high availability of...
Preface This article mainly summarizes some of th...
Use the --all-database parameter when performing ...
Table of contents Preface 1. Arrange the installa...
This article example shares the specific code of ...
1. Varnish Overview 1. Introduction to Varnish Va...
High CPU load caused by MySQL This afternoon, I d...
For example, when you create a new table or updat...
This is the effect of the Element UI loading comp...
To back up multiple databases, you can use the fo...
The so-called cascading replication is that the m...
<br />Simple example of adding and removing ...
Being an operation and maintenance engineer is a ...
1. <dl> defines a list, <dt> defines ...