Solve the problem of not connecting to MySQL in the LNMP environment

Source: Internet
Author: User
Tags mysql in iptables

Remote connection of MySQL database in LNMP environment


First, for the sake of security, LNMP environment is forbidden remote connection, he will delete the iptables inside the 3306 Port firewall rule



First, if it is phpmydmin to the authority to the remote connection to the user host to change to *
Reference:
Https://bbs.vpser.net/thread-3135-1-1.html


Or
Mysql-uroot-p Enter password


Use MySQL;
Update user Set host = '% ' where user= ' root ';


Flush privileges;


Exit


Root can be replaced by our user name


If you do not create a user, perform
Grant all privileges the on database name. * To user name @ '% ' identified by ' password ';


For example: Grant all privileges the mysql.* to ' root ' @ ' percent ' identified by ' 123456 ';


Displays all iptables as an ordinal tag, executing:
Iptables-l-N--line-numbers


Add 3306 port number to firewall


Iptables-i input-p TCP--dport 3306-j ACCEPT
Service Iptables Save


Service Iptables Restart


Service MySQL Restart


Then use the Mysqlyog connection database to try, you can first use the test connection test in the lower right corner of the Mysqlyog





Second, in order to be safe, the LNMP environment is forbidden to connect remotely, he will remove the firewall rule of the 3306 port inside the iptables


Iptables Delete the drop 3306 port


Reference Iptables Tutorials
Htttps://www.vpser.net/security/linux-iptables.html


To delete a iptables rule that has been added
Displays all iptables as an ordinal tag, executing:
Iptables-l-N--line-numbers


For example, to delete the rule execution with the sequence number 8 in input:
Iptables-d INPUT 8















This article is from the "12252646" blog, please be sure to keep this source http://12262646.blog.51cto.com/12252646/1947251

Solve the problem of not connecting to MySQL in the LNMP environment

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.