Linux open MySQL remote connection method and problem solving methods

Source: Internet
Author: User
Tags iptables

Linux open MySQL Remote connection method

1. Grant command create remote connection MySQL authorized user root

Mysql-u root-p
Mysql>grant all privileges in *.* to root@localhost identified by ' 123456 ' with GRANT OPTION;

Increase root user authorization via local machine (localhost) access, password "123456".

Mysql>grant all privileges in *.* to root@ "%" identified by ' 123456 ' with GRANT OPTION;

Grant access from any other host by the root user (% of the wildcard character).

2, set the firewall allow 3306 ports

Vi/etc/sysconfig/iptables

Add to:

-A rh-firewall-1-input-m state–state new-m tcp-p tcp–dport 3306-j ACCEPT

(Note that the rule will not take effect until the-a rh-firewall-1-input-j reject–reject-with icmp-host-prohibited is added)
Reboot the firewall:

Service Iptables Restart

Troubleshoot problems with MySQL not being able to connect remotely

1, the MySQL port is correct
Check the port occupancy through the NETSTAT-NTLP, generally the bottom of the mouth is 3306. The port is used to connect MySQL with the tool. For example, my adminmy Query browsermysql front.

2, check the user rights are correct
The MySQL library has two records in the user table: the host is localhost and% (for security,% can be replaced by the IP you need to have external connections).

3, check the/ETC/MYSQL/MY.CNF, Skip-networking has been injected
Need to be injected
Error: Error 2003 (HY000): Can ' t connect to MySQL server on ' 192.168.51.112 ' (111)


sudo gedit/etc/mysql/my.cnf
#skip-external-locking

#bind-address = 127.0.0.1

Skip-name-resolve

4, to see whether the iptables stopped, not closed the case, can not connect
Through: Service iptables stop temporary shutdown.
Error: Error 2003 (HY000): Can ' t connect to MySQL server on ' 192.168.51.112 ' (113)

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.