CentOS7 and CentOS6 How to turn on MySQL remote access

Source: Internet
Author: User
Tags iptables

CentOS6 turn on MySQL remote access

1. Open MySQL Access port 3306

Modify the firewall configuration file

Vi/etc/sysconfig/iptables

Join Port Configuration

-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT

Reload Rule

Service Iptables Restart


2. Modify the host in the MySQL library

Log in to MySQL;

Use MySQL

Update user set host= '% ' where user= ' root ' and host= ' localhost ';

Remember must also change the password, because at this time the password is invalid, although the local can also be the original password to log in, can be remotely changed host or cannot access

UPDATE user SET Password=password ("root") WHERE user= ' root ';

Flush privileges;

3. Restart MySQL, remote access to the

Service mysqld Restart;


CentOS7 turn on MySQL remote access

CentOS7 This version of the firewall uses the default firewall, unlike the previous version using iptables . Configure the firewall as follows:

1. Turn off the firewall:sudo systemctl stop firewalld.service


2, turn off boot: sudo systemctl disable firewalld.service

3. Install iptables firewall

Execute the following command to install the Iptables firewall:Sudo yum install iptables-services

?

4, configure iptables firewall, open the specified port (CentOS6 same)

5, set up iptables firewall boot:Sudo systemctl enable iptables

6, after the same as CentOS6



Basic operational commands for the firewall under CentOS

CentOS Configuration Firewall Operation instance (start, stop, open, closed port):

Note: The basic operation of the firewall command:

Querying firewall Status:

[[Email protected] ~]# service iptables status

To stop the firewall:

[[Email protected] ~]# service iptables stop

To start the firewall:

[[Email protected] ~]# service iptables start

To restart the firewall:

[Email protected] ~]# service iptables restart

To permanently shut down the firewall:

[Email protected] ~]# chkconfig iptables off

Enable after permanent shutdown:

[Email protected] ~]# chkconfig iptables on

1. View firewall status

[[Email protected] ~]# service iptables status

2, edit the/etc/sysconfig/iptables file. We're going to open 8080 ports and 9990 ports in our instance.

Open/etc/sysconfig/iptables with editor


4. Save the/etc/sysconfig/iptables file and execute it at the terminal

[Email protected] ~]# service iptables restart


5. New view of firewall status

[[Email protected] ~]# service iptables status


6, this time, the server's 8080 and 9990 ports can provide services to the outside.

7, other ports open mode is similar to the open mode.

CentOS7 and CentOS6 How to turn on MySQL remote access

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.