In Linux, the configuration of MySQL remote access settings is described a lot on the Internet, but the actual operation is still a lot of trouble, record it (Attention should be paid to the red area.).
The first step is the same as configuring mysql remote logon in Winddows. Generally, You can execute the following statement:
- Use mysql;
- GRANT ALL ON*.*TOAdmin @'%'IDENTIFIEDBY 'Admin' WITH GRANT OPTION;
- GRANT ALL ON*.*TOAdmin @'Localhost'IDENTIFIEDBY 'Admin' WITH GRANT OPTION;
- FlushPrivileges
In fact, you have created a User Username: admin Password: admin to log on remotely.
Step 2: Open the Firewall
It is not easy to simply close the firewall.
Stop the Firewall service iptables stop and then modify/etc/sysconfig/iptables
Add-A input-m state -- state NEW-m tcp-p tcp -- dport 3306-j ACCEPT
- -A input-m state -- state NEW-m tcp-p tcp -- dport22-J ACCEPT
- -A input-m state -- state NEW-m tcp-p tcp -- dport3306-J ACCEPT
- -A input-j REJECT -- reject-with icmp-host-prohibited
- -A forward-j REJECT -- reject-with icmp-host-prohibited
Note that the added location must be in
- -A input-j REJECT -- reject-with icmp-host-prohibited
- -A forward-j REJECT -- reject-with icmp-host-prohibited
Above.
Then start the Firewall:
Service iptables start
If the problem persists, modify the following configuration:/etc/my. cnf.
[Mysqld] add
- Skip-name-resolve
- Bind-address =0.0.0.0
If the my. cnf file cannot be found, copy the my-small.cnf to/etc and rename my. cnf.
Do not know the location of the my-small.cnf with find/-name my-small.cnf