Configure MySQL remote access in Linux

Source: Internet
Author: User

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:

  1. Use mysql;
  2. GRANT ALL ON*.*TOAdmin @'%'IDENTIFIEDBY 'Admin' WITH GRANT OPTION;
  3. GRANT ALL ON*.*TOAdmin @'Localhost'IDENTIFIEDBY 'Admin' WITH GRANT OPTION;
  4. 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

  1. -A input-m state -- state NEW-m tcp-p tcp -- dport22-J ACCEPT
  2. -A input-m state -- state NEW-m tcp-p tcp -- dport3306-J ACCEPT
  3. -A input-j REJECT -- reject-with icmp-host-prohibited
  4. -A forward-j REJECT -- reject-with icmp-host-prohibited

Note that the added location must be in

  1. -A input-j REJECT -- reject-with icmp-host-prohibited
  2. -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

  1. Skip-name-resolve
  2. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.