Remote login to mysql5.7 server
My remote login system is Mac os.
NancylulululudeMacBook-Air:bin nancy$ mysql-h 172.16.158.132-u root-p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '172.16.158.132' (61)
Can communicate with ping
NancylulululudeMacBook-Air:bin nancy$ ping 172.16.158.132
PING 172.16.158.132 (172.16.158.132): 56 data bytes
64 bytes from 172.16.158.132: icmp_seq=0 ttl=64 time=1.361 ms
64 bytes from 172.16.158.132: icmp_seq=1 ttl=64 time=1.622 ms
64 bytes from 172.16.158.132: icmp_seq=2 ttl=64 time=0.399 ms
It should be the port.
Log in to MySQL server
View mysql port
[root@nancycici src] # netstat-apn | grep 3306
Tcp6 0 0: 3306: * LISTEN 36866/mysqld
View Port Firewall
[root@nancycici src] # firewall-cmd-- query-port=3306/tcp
No
Modify Port
[root@nancycici src] # firewall-cmd-zone=public-add-port=3306/tcp-permanent
Success
[root@nancycici src] # firewall-cmd-- query-port=3306/tcp
No
Reload
[root@nancycici src] # firewall-cmd-- reload
Success
[root@nancycici src] # firewall-cmd-- query-port=3306/tcp
Yes
Client logged in successfully
NancylulululudeMacBook-Air:bin nancy$ mysql-h 172.16.158.132-u root-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or\ g.
Your MySQL connection id is 24
Server version: 5.7.25 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.
-D login database
Mysql-h 172.16.158.132-D nancyuser-u root-p