"Go" ERROR 2003 (HY000): Can ' t connect to MySQL server on ' 192.168.1.165 ' (113)

Source: Internet
Author: User
Tags symlink

Translated from: http://blog.csdn.net/chengyuqiang/article/details/54285857

1, the program error :
Com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:Communications Link
2. Try to connect to the database remotely :
[Email protected] ~]# mysql-h192.168.1.165-uroot-p123456
ERROR 2003 (HY000): Can ' t connect to MySQL server on ' 192.168.1.165 ' (113)

3, the problem was found, can not connect to the remote database.

4. Test if you can ping the remote machine

[[email protected] ~]# Ping 192.168.1.165

PING 192.168.1.165 (192.168.1.165) bytes of data.
Bytes from 192.168.1.165:icmp_seq=1 ttl=128 time=0.776 ms
Bytes from 192.168.1.165:icmp_seq=2 ttl=128 time=1.26 ms
Bytes from 192.168.1.165:icmp_seq=3 ttl=128 time=1.19 ms
^c
---192.168.1.165 ping statistics---
3 Packets transmitted, 3 received, 0% packet loss, time 2008ms
RTT Min/avg/max/mdev = 0.776/1.078/1.268/0.215 ms

Indicates that the network is connected, and then test the following port number


5. Log on to the database side

[Email protected] ~]# mysql-uroot-p123456
Welcome to the MariaDB Monitor. Commands End With; or \g.
Your MariaDB Connection ID is 11
Server VERSION:5.5.52-MARIADB MariaDB Server
Copyright (c), Oracle, MariaDB Corporation Ab and others.
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
MariaDB [(None)]> select User,host,password from Mysql.user;
+------+-----------+-------------------------------------------+
| user | Host | password |
+------+-----------+-------------------------------------------+
| Root | localhost | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 |
| Root | 127.0.0.1 | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 |
| Root | :: 1 | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 |
+------+-----------+-------------------------------------------+

Add

MariaDB [(None)]> Grant all privileges on * * to ' root ' @ '% ' identified by ' 123456 ';
Query OK, 0 rows Affected (0.00 sec)

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


Remote Access again:

[Email protected] ~]# mysql-h192.168.1.165-uroot-p123456
ERROR 2003 (HY000): Can ' t connect to MySQL server on ' 192.168.1.165 ' (113)


6, or cannot connect to the database, may not be able to access the port number, test again

[[Email protected] ~]# telnet 192.168.1.165 3306
Trying 192.168.1.165 ...
Telnet:connect to address 192.168.1.165:no route to host

Find out where the problem is and the firewall blocks the port number.

7, directly shut down the firewall can .

[Email protected] ~]# systemctl disable FIREWALLD
Removed Symlink/etc/systemd/system/dbus-org.fedoraproject.firewalld1.service.
Removed Symlink/etc/systemd/system/basic.target.wants/firewalld.service.
[[Email protected] ~]# service FIREWALLD stop
Redirecting To/bin/systemctl Stop Firewalld.service

Remote Access again

[[Email protected] ~]# telnet 192.168.1.165 3306
Trying 192.168.1.165 ...
Telnet:connect to address 192.168.1.165:no route to host
[Email protected] ~]# mysql-h192.168.1.165-uroot-p123456
Welcome to the MariaDB Monitor. Commands End With; or \g.
Your MariaDB Connection ID is 7
Server VERSION:5.5.52-MARIADB MariaDB Server

Copyright (c), Oracle, MariaDB Corporation Ab and others.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

MariaDB [(None)]>

It worked.


ERROR 2003 (HY000): Can ' t connect to MySQL server issue

Solution Summary:

1, determine the remote machine firewall shutdown, or the firewall allows 3306 port number

2. Make sure the database allows remote access via the statement grant all privileges on * * to ' root ' @ '% ' identified by ' 123456 '.

"Go" ERROR 2003 (HY000): Can ' t connect to MySQL server on ' 192.168.1.165 ' (113)

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.