Turn on MySQL remote access permission
The default MySQL user does not have remote access permission, so when the program is not on the same server as the database, we need to turn on MySQL remote access.
There are two main ways to change the table method and the authorization law.
Relatively speaking, it is easier to change the table method, the individual is also more inclined to use this method, so, here only to paste the table method
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 is to allow any host access, if only one IP access, you can change to the corresponding IP, such as can be changed to 192.168.1.123, this means that only allow LAN 192.168.1.123 this IP remote access to MySQL.
mysql> use mysql;mysql > Update user set host = '% ' where user = ' root '; MySQL> Select Host , user from user; MySQL> Flush privileges;
Firewall Open 3306 Port
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 added open 3306-port statement must be preceded by the icmp-host-prohibited
Attached: Personal configuration
#Firewall configuration written by System-config-firewall#Manual Customization of this file are 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--stateNEW-M tcp-p TCP--dport 22-J ACCEPT-A input-m State--stateNEW-M Tcp-p TCP--dport 80-J ACCEPT-A input-m State--stateNEW-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-Prohibitedcommit
MySQL opens remote access and firewall open port 3306 under Linux