Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
unix  3      [ ]         STREAM     CONNECTED     4542200  /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.

share|improve this question

2 Answers 2

MySQL uses the UNIX socket on localhost - much faster. It won't run on a TCP port unless you tell it to do so.

share|improve this answer

Have you checked your iptables settings?

sudo iptables -L -v
share|improve this answer
    
I have disabled firewall temporarily with "sudo ufw disable". Does it stop iptables also? –  Bakhtiyor Oct 16 '11 at 16:41
    
@Bakhtior yes: ufw is a simplified frontend to iptables. –  Riccardo Murri Oct 16 '11 at 16:50
    
So, why I am not able to telnet to mysql then? –  Bakhtiyor Oct 16 '11 at 16:51
1  
@Bakhtiyor Just a clarification: you say "When trying to connect to the MySQL server I get this error ..." and then "I can connect via ... once I'm in the server" Does this mean that you're trying the telnet localhost command on a host which is not the MySQL server host? –  Riccardo Murri Oct 16 '11 at 16:54
    
First I am connecting to the server with ssh, and then right from the server I am executing telnet command. –  Bakhtiyor Oct 16 '11 at 17:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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