In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to open remote access and firewall 3306 port on mysql under linux". In the operation of actual cases, many people will encounter this dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Enable remote access to mysql
The user who defaults to mysql does not have remote access, so when the program is not on the same server as the database, we need to enable remote access to mysql.
There are two mainstream methods, the table change method and the authorization law.
Relatively speaking, the table change method is relatively easy, and individuals are more inclined to use this method, so only the meter change method is posted here.
1. Log in to mysql
Mysql-u root-p
2. Modify the user table of the mysql library and change the host entry from localhost to%. % here means that arbitrary host access is allowed. If only one ip access is allowed, it can be changed to the corresponding ip. For example, the localhost can be changed to 192.168.1.123, which means that only 192.168.1.123 ip of the local area network is allowed to access the mysql remotely.
Mysql > use mysql
Mysql > update user set host ='% 'where user =' root'
Mysql > select host, user from user
Mysql > flush privileges
Firewall opens port 3306
1. Open the firewall configuration file
Vi / etc/sysconfig/iptables
2. Add the following line
-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 3306-j ACCEPT
3. Restart the firewall
Service iptables restart
Note: the addition of open port 3306 statements must precede icmp-host-prohibited
Attached: 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]
-An INPUT-m state-- state ESTABLISHED,RELATED-j ACCEPT
-An INPUT-p icmp-j ACCEPT
-An INPUT-I lo-j ACCEPT
-An INPUT-I eth0-j ACCEPT
-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 22-j ACCEPT
-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 80-j ACCEPT
-An 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
-An INPUT-j REJECT-- reject-with icmp-host-prohibited
-A FORWARD-j REJECT-- reject-with icmp-host-prohibited
COMMIT
This is the end of the content of "how to open remote access for mysql and open port 3306 for firewall under linux". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.