3

When trying to connect to mysql server via telnet I am getting following error:

telnet localhost 3306
Trying ::1...
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection timed out

I tried telnet with 127.0.0.1, hostname also, but getting same error message. But I can connect with mysql -u username -p once I am in the server.

Here is the result of netstat:

netstat -na | grep mysql
unix  2      [ ACC ]     STREAM     LISTENING     4540495  /var/run/mysqld/mysqld.sock

netstat -na | grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN  

What could be possible problems? If you need some more details I could provide it without any problems.

Thanks a lot.

Bakhtiyor
  • 171
  • 1
  • 2
  • 7
  • Are you able to provide the output of iptables-save? Can you also try to telnet to the host using the non-localhost IP address of the machine (so, for example 192.168.1.1)? – Matthew Ife Nov 15 '11 at 21:39

2 Answers2

3

Can you connect with:

mysql -h127.0.0.1 -u username -p

If not, check whether your server was started 'skip-networking' enabled:

If the server was started with --skip-networking, it will not accept TCP/IP connections at all. src

Which indicates 127.0.0.1 will not work, but localhost will. In mysql localhost and 127.0.0.1 are different hosts.

Further things to check:

  • are you running the default port (3306)? Check your my.cnf or do mysqladmin -h localhost -p variables | grep port

  • If you are running under Linux and Security-Enhanced Linux (SELinux) is enabled, make sure you have disabled SELinux protection for the mysqld process.

Derek Downey
  • 3,955
  • 4
  • 27
  • 29
1

I got same problem and i resolved . I use Mac pro & sequel Pro as mysql client , socket localhost connection succeeded but standard tcp/ip Connection failed!
and I check my running port by using cmd :

mysqladmin -h localhost -u root -p variables | grep port

here is my result status:

wangxiaodeMacBook-Pro:~ wangxiao$ mysqladmin -h localhost -u root -p variables | grep port
Enter password: 
| innodb_support_xa                                      | ON                                                                                                                                                                                                                                                                                                                                               |
| large_files_support                                    | ON                                                                                                                                                                                                                                                                                                                                               |
| port                                                   | 3307                                                                                                                                                                                                                                                                                                                                             |
| report_host                                            |                                                                                                                                                                                                                                                                                                                                                  |
| report_password                                        |                                                                                                                                                                                                                                                                                                                                                  |
| report_port                                            | 3307                                                                                                                                                                                                                                                                                                                                             |
| report_user                                            |                       

It's porting 3307 not default 3306 , there was another mysql server installed once . so change it and resolved. tks @DTest 's answer.

HBruijn
  • 77,029
  • 24
  • 135
  • 201
南无增
  • 11
  • 2
  • Welcome to ServerFault. Thank you posting your answer ; although it does not really add al that much more to the already existing answer, especially without proper formatting. To show appreciation please vote up any useful answer and not just say thank you. Hope you stay around will become another active community member. – HBruijn Sep 10 '15 at 05:55