Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. 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

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
    
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
add comment

1 Answer 1

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.

share|improve this answer
    
mysql -h localhost -u username -p works fine but mysql -h 127.0.0.1 -u username -p says ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (110) –  Bakhtiyor Nov 15 '11 at 20:43
    
How to see whether it is started with --skip-networking or not? –  Bakhtiyor Nov 15 '11 at 20:43
    
If you log in on localhost, do SHOW VARIABLES LIKE 'skip_networking' –  DTest Nov 15 '11 at 20:45
    
I have ubuntu and have revised my.cnf for skip-networking parameter. I didn't find any record saying skip-networking. –  Bakhtiyor Nov 15 '11 at 20:46
    
SHOW VARIABLES LIKE 'skip_networking' is showing skip_networking | OFF | –  Bakhtiyor Nov 15 '11 at 20:47
show 3 more comments

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.