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.

I have mailserver configure using dovecot+postfix+mysql and it was runnig fine in the server(Ubuntu Server). But during last week it stopped working correctly. It doesn't send email. When I try to telnet localhost smtp I'm connecting successfully but when I do mail from:<steve@example.com> and hit Enter it hangs on, nothing happen.

Having reviewed /var/log/mail.log file I've found out that probably(99%) the problem is on postfix when it is trying to connect to MySQL server. If you see the log file given below you can see that it says Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2).

Nov 14 21:54:36 ns1 dovecot: dovecot: Killed with signal 15 (by pid=7731 uid=0 code=kill)
Nov 14 21:54:36 ns1 dovecot: Dovecot v1.2.9 starting up (core dumps disabled)
Nov 14 21:54:36 ns1 dovecot: auth-worker(default): mysql: Connected to localhost (mailserver)
Nov 14 21:54:44 ns1 postfix/postfix-script[7753]: refreshing the Postfix mail system
Nov 14 21:54:44 ns1 postfix/master[1670]: reload -- version 2.7.0, configuration /etc/postfix
Nov 14 21:54:52 ns1 postfix/trivial-rewrite[7759]: warning: connect to mysql server localhost: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Nov 14 21:54:52 ns1 postfix/trivial-rewrite[7759]: fatal: mysql:/etc/postfix/mysql-virtual-alias-maps.cf(0,lock|fold_fix): table lookup problem
Nov 14 21:54:53 ns1 postfix/master[1670]: warning: process /usr/lib/postfix/trivial-rewrite pid 7759 exit status 1
Nov 14 21:54:53 ns1 postfix/cleanup[7397]: warning: problem talking to service rewrite: Connection reset by peer
Nov 14 21:54:53 ns1 postfix/master[1670]: warning: /usr/lib/postfix/trivial-rewrite: bad command startup -- throttling
Nov 14 21:54:53 ns1 postfix/smtpd[7071]: warning: problem talking to service rewrite: Success

I tried netstat -ln | grep mysql and it returns

unix 2 [ ACC ] STREAM LISTENING 5817 /var/run/mysqld/mysqld.sock.

The content of /etc/postfix/mysql-virtual-alias-maps.cf file is here:

user = stevejobs
password = apple
hosts = localhost
dbname = mailserver
query = SELECT destination FROM virtual_aliases WHERE source='%s'

Here I tried to change hosts = 127.0.0.1 but it says warning: connect to mysql server 127.0.0.1: Can't connect to MySQL server on '127.0.0.1' (110)

So, I am lost and don't know where else to change in order to solve the problem. Any help would be appreciated highly.

Thank you.

EDIT 1

When I do netstat -na I see that mysql is not bind neither to localhost nor to 127.0.0.1. Could it be the problem also?

bakhtiyor@ns1:~$ netstat -na | grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN   
share|improve this question
add comment

5 Answers 5

up vote 5 down vote accepted

It seems very stupid but I have solved the problem. I hadn't noticed that a system administrator somehow blocked 3306 port for all hosts at the firewall, and therefore I couldn't connect to mysql. After removing that restriction I was able to connect to mysql without any problems. Thanks for your suggestions and help.

share|improve this answer
    
How to remove restriction? –  Green Jul 19 '13 at 3:32
add comment

Have you tried to connect to the Mysql server?

mysql -u username -p

Also, you can try change the listen address in /etc/mysql/my.cnf to 127.0.0.1 and restart MySQL

# /etc/mysql/my.cnf
bind-address = 127.0.0.1
share|improve this answer
    
I did all you said and no results –  Bakhtiyor Nov 14 '11 at 19:28
    
i mean i can connect to mysql using mysql -u username -p –  Bakhtiyor Nov 15 '11 at 9:07
    
Should be "my.cnf" –  jnunn Feb 8 '13 at 16:27
add comment

I had a similar problem. Changing "hosts = localhost" to "hosts = 127.0.0.1" and setting bind-address to the same address fixed it for me (bind-address was set at 0.0.0.0 for some reason)

share|improve this answer
add comment

I was just getting this same error on one of the company computers.

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

I was also getting this error a lot when I tried to run X-windows programs through ssh:

GConf Error: Failed to contact configuration server; 
some possible causes are that you need to enable TCP/IP networking for ORBit,
or you have stale NFS locks due to a system crash

Turns out I had a root file system that was completely filled up, with no free disk space, so my system couldn't write a lot of necessary files. I was getting all sorts of errors, related to many different programs. (Couldn't log in through GDM, GDM wallpaper went black, gconf lock file errors, etc...)

All I did was enter this simple command to get rid of over 400 MB worth of files in the root partition that were no longer needed.

sudo apt-get autoremove

That gave my root file system the breathing space it needed. Now everything runs great. Guess a 10 GB root directory isn't enough to handle over two years worth of Ubuntu updates.

If anybody cares, the system has been running Ubuntu 10.04 since it came out. The system updates at least once a week. Today's date is 9-6-2012, so that's almost 2 1/2 years worth of updates.

share|improve this answer
    
when your problem is space, I also suggest askubuntu.com/questions/17432/… –  ecoologic Jan 20 '13 at 0:42
    
+1 for pointing out space issue -- this solved my problem. –  yuval May 30 '13 at 20:26
add comment

What finally helped me was purging (not removing!) all the apt-get packages related to mysql except for libmysqlclient16 which was in de-install status (not sure what that is).

So, just do:

dpkg --get-selections | grep mysql

and then:

sudo apt-get purge <package_name>

Start from common then go to client and then the server.

share|improve this answer
add comment

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.