0

I know that this question looks duplicate with many others, but before you downvote me, I already read about others related questions but didn't solve my problem. Please take a look about my environment:

$ ps -Af | grep mysqld
mysql      901     1  0 10:11 ?        00:00:00 /usr/sbin/mysqld
ubuntu    3229  2542  0 10:13 pts/0    00:00:00 grep --color=auto mysqld  

More output:

# netstat -lnp | grep mysql
tcp        0      0 0.0.0.0:3306
unix  2      [ ACC ]     STREAM     LISTENING     19274    901/mysqld           /var/run/mysqld/mysqld.sock

I think this will be useful too:

$ cat /etc/mysql/mysql.conf.d/mysqld.cnf | grep bind-address
bind-address = 0.0.0.0

There is no skip-networking option active, but even so, I can access the MySQL through local socket connection!

Already added 3306 to ufw allow-list, and even more, tried to connect with ufw disabled.

neither 127.0.0.1, or my lan ip 192.168.1.100 or 0.0.0.0 works, I keep getting the same output error:

ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (97)

Here is the nmap on port 3306:

# nmap -sS -O -p3306 127.0.0.1
PORT     STATE SERVICE
3306/tcp open  mysql

The telnet output:

$ telnet 127.0.0.1 3306
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
[
5.7.21-0ubuntu0.17.10.1!5GAC"?0)kLQBLmysql_native_passwordConnection closed by foreign host.

A few interesting lines on the error.log:

2018-04-12T13:28:58.588887Z 0 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
2018-04-12T13:28:58.588895Z 0 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
2018-04-12T13:28:58.588919Z 0 [Note] Server socket created on IP: '0.0.0.0'.
2018-04-12T13:28:58.593960Z 0 [Note] Event Scheduler: Loaded 0 events
2018-04-12T13:28:58.594091Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.21-0ubuntu0.17.10.1'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)

In my point of view, it should be working fine... Any help will be welcome!

=)

[Update]

Added the iptables output after been requested. # iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination  
4
  • Right, we need to know what client is trying to connect to MySQL, and how it is configured to do so. Apr 12, 2018 at 21:09
  • I'm trying to use mysql-client 5.7 with a simple: $ mysql -u root -p -h 127.0.0.1 Apr 12, 2018 at 23:13
  • You have GRANTed the root user permission to connect remotely, haven't you...?
    – roaima
    Apr 12, 2018 at 23:42
  • I Think I didn't, how do I check in a easy way if I had? In the cnf file? Apr 13, 2018 at 19:39

1 Answer 1

0

Comment out the bind-address line. Commenting out that line will force the MySQL server to accept connections regardless of origin. In theory setting 0.0.0.0 should do the same however I personally have had difficulties with that before.

Commenting out the bind address line will mean there is no questions about whether or not the change stuck. Comment how this goes, we’ll find you a solution one way or another

6
  • Hi Timothy, i did comment the bind-address line in the cnf file, but I'm still getting the same behavior and output for the commands that I presented on the question. =/ Apr 12, 2018 at 23:19
  • @Mateus and restarted MySQL...?
    – roaima
    Apr 12, 2018 at 23:32
  • Yes, and rechecked the error.log file. Nothing relevant happened. Apr 13, 2018 at 19:38
  • Can you also try iptables -L and check the ufw stuff is actually in there and enabled Apr 13, 2018 at 19:40
  • I think there are no routes, added the output of the command on the question. Apr 15, 2018 at 21:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.