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.

My mail server (Ubuntu 10.04) uses mysql for virtual domains, virtual users. For some reason, mysqld has started refusing connections from localhost. I see these in the mail server log:

Oct 6 00:31:14 apollo postfix/trivial-rewrite[16888]: fatal:
proxy:mysql:/etc/postfix/mysql-virtual_domains.cf(0,lock|fold_fix): table
lookup problem

and:

Oct 7 13:39:15 apollo postfix/proxymap[25839]: warning: connect to mysql server
127.0.0.1: Lost connection to MySQL server at 'reading initial communication
packet', system error: 0

I also get the following in auth.log:

Oct 6 22:33:31 apollo mysqld[31775]: refused connect from 127.0.0.1

Telnet to the local port:

root@apollo:/var/log/mysql# telnet localhost 3306
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
root@apollo:/var/log/mysql#

I am not sure why this started happening, but there was a disk failure in a RAID 1 pair a bit earlier that day. So it's possible I have a damaged config file or something. But mail was working for at least an hour after the drive event, so who knows for sure?

phpmyadmin works fine, and the databases themselves look like they're intact.

I think/believe that selinux and iptables are disabled and not running. So ... why is mysqld refusing connections from localhost? What should I check? What processes might cause this if a .conf file or possibly a binary was damaged? Which other log files might contain clues? I've enabled "general logging" in /etc/mysql/my.cnf, but I get no interesting or informative entries there.

Thanks, m00tpoint

share|improve this question

migrated from stackoverflow.com Oct 8 '12 at 9:19

This question came from our site for professional and enthusiast programmers.

    
Why are you using telnet to get to the MySQL server? Why not just use the mysql client? Also, previous questions on SO suggest this might be an iptables problem. stackoverflow.com/questions/5755819/… –  Chris Henry Oct 7 '12 at 21:18

3 Answers 3

Did you check the actual mysql log file?

/var/lib/mysql/"your-server-name".err

Also maybe you reach you limit of max_connections. run this command to check out:

show variables like 'max_connections';
show status like 'Max_used_connections';

if max_connections and Max_used_connections are equal than you need to raise max_connections

share|improve this answer

Despite the fact that localhost is normally equivalent to 127.0.0.1, as far as MySQL is concerned the two are distinct entities.

The part of the Telnet log you included shows Telnet trying first to connect by name and failing. It then tried by IP address and succeeded. Despite the fact that Telnet then reported that it had connected to MySQL at localhost, the MySQL user account is apparently configured for 127.0.0.1. I suspect that the two identities have been changed in some config file. I don't know postfix but I suggest you check its config. Failing that you could add a MySQL user account for 27.0.0.1.

share|improve this answer
    
The log posted doesn't show telnet trying to connect to anything by name and failing. It does show a failure to connect to ::1, though, which is quite worrisome. –  Michael Hampton Oct 8 '12 at 13:40

to start troubleshooting your issue, try netstat command as following:

# netstat -anp | egrep '3306.*LISTEN'
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      4118/mysqld         
# 

and/or try this:

mysql --socket=/var/lib/mysql/mysql.sock

replace /var/lib/mysql/mysql.sock with appropriate path to your mysql.sock file.

also, since you said you have phpMyAdmin running, why don't you look in config.inc.php and see how it's connecting to your mysqld.

possibly that binding of your mysqld is on a specific IP/interface and not on all.

share|improve this answer

Your Answer

 
discard

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