Navicat installing MySQL in a remote access VM

Source: Internet
Author: User
Tags mysql in iptables

First: The firewall used by CentOS 7 is: Firewall not iptables

To view the ports that are already open: Here I've opened the MySQL port

[Email protected] ~]# Firewall-cmd--list-ports
3306/tcp

Open port: Prompt success indicates success

[Email protected] ~]# firewall-cmd--zone=public--add-port=3306/tcp--permanent
Success

Meaning of the command:

--zone # indicates scope

--add-port=3306/tcp #添加端口 in the format: port number/Communication protocol

--permanent #永久生效, fail after reboot without this parameter

Need to restart the firewall:

Firewall-cmd--reload #重启firewall

Systemctl Stop Firewalld.service #停止firewall

Systemctl Disable Firewalld.service #禁止firewall开机启动

viewing ports for listening (Listen)

Netstat-lntp

Check which process the port is using

Netstat-lnp|grep 8080

After restarting the firewall, you need to set up a remote access account in MySQL

[Email protected] ~]# mysql-uroot-p
Enter Password:
Welcome to the MariaDB Monitor. Commands End With; or \g.
Your MariaDB Connection ID is 4
Server VERSION:5.5.60-MARIADB MariaDB Server
Copyright (c), 2018, Oracle, MariaDB Corporation Ab and others.
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

MariaDB [(None)]> create user ' username ' @ '% ' identified by ' password ';
Query OK, 0 rows Affected (0.00 sec)

MariaDB [(None)]> grant all on * * ' username ' @ '% ';
Error 1064 (42000): You have a error in your SQL syntax; Check the manual, corresponds to your MariaDB server version for the right syntax "@ '" @ '% ' @ Line 1
MariaDB [(None)]> grant all on * * to ' zhengwei ' @ '% ';
Query OK, 0 rows Affected (0.00 sec)

MariaDB [(None)]> flush privileges;
Query OK, 0 rows Affected (0.00 sec)

Then test the connection successfully locally!

CentOS 7 following version iptables command

To open the 80,22,8080 port, enter the following command

-I INPUT -p tcp --dport 80 -j ACCEPT2、/sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT3、/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

Then Save:

/etc/rc.d/init.d/iptables save

To view open ports:

/etc/init.d/iptables status

Shutting down the firewall
1) Permanent, no recovery after reboot

Open: Chkconfig iptables on

OFF: Chkconfig iptables off

2) immediate effect, recovery after restart

Open: Service iptables start

Close: Service iptables stop

Navicat installing MySQL in a remote access VM

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.