Can't connect to MySQL server on '127.0.0.1' (61)

started at 12 Mar 2008 by Rimas
  • Rimas
    12 Mar 2008

    Hi!

    What an excellent source of information this web site is...!!! I got MySQL, Apache and PHP all successfully working. However, I am struggling to get even a basic mail server up and running. After building, installing, configuring and starting all of the required pieces, I find that I am unable to send or receive e-mail. Looking in /var/log/mail.log I see the same pattern of messages repreated every 60 seconds or so:


    Mar 12 16:00:10 MacMiniServer postfix/trivial-rewrite[584]: warning: connect to mysql server 127.0.0.1: Can't connect to MySQL server on '127.0.0.1' (61)
    Mar 12 16:00:10 MacMiniServer postfix/trivial-rewrite[584]: fatal: mysql:/etc/postfix/mysql_virtual_alias_maps.cf(0,lock|fold_fix): table lookup problem
    Mar 12 16:00:11 MacMiniServer postfix/smtpd[488]: warning: problem talking to service rewrite: Unknown error: 0
    Mar 12 16:00:11 MacMiniServer postfix/smtpd[347]: warning: problem talking to service rewrite: Unknown error: 0
    Mar 12 16:00:11 MacMiniServer postfix/master[286]: warning: process /usr/libexec/postfix/trivial-rewrite pid 584 exit status 1
    Mar 12 16:00:11 MacMiniServer postfix/master[286]: warning: /usr/libexec/postfix/trivial-rewrite: bad command startup -- throttling

    I am able to connect to MySQL from a cmd line:


    MacMiniServer:~ Rimas$ mysql --user=Rimas --password=********
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 67
    Server version: 5.0.51a-standard-log Source distribution

    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

    mysql> use mysql
    Database changed
    mysql> select host, user, password, select_priv from user;
    +---------------------+-----------+-------------------------------------------+-------------+
    | host | user | password | select_priv |
    +---------------------+-----------+-------------------------------------------+-------------+
    | localhost | Rimas | *972D8E7C521419D7E52E96B357E80789D622948D | Y |
    | MacMiniServer.local | Rimas | *972D8E7C521419D7E52E96B357E80789D622948D | Y |
    | 127.0.0.1 | Rimas | *972D8E7C521419D7E52E96B357E80789D622948D | Y |
    | localhost | mailsrvr | *972D8E7C521419D7E52E96B357E80789D622948D | N |
    | localhost | mailadmin | *972D8E7C521419D7E52E96B357E80789D622948D | N |
    +---------------------+-----------+-------------------------------------------+-------------+
    5 rows in set (0.00 sec)

    mysql> select host, db, user, select_priv from db;
    +-----------+---------+-----------+-------------+
    | host | db | user | select_priv |
    +-----------+---------+-----------+-------------+
    | localhost | postfix | mailsrvr | Y |
    | localhost | postfix | mailadmin | Y |
    +-----------+---------+-----------+-------------+
    2 rows in set (0.00 sec)

    mysql> exit

    Just to make sure it was a problem connecting to MySQL, I edited /etc/postfix/main.cf and changed


    virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf

    to


    virtual_alias_maps = ********.org

    and after restarting Postfix the can't connect to MySQL error moved to the next item (i.e. mysql_virtual_domains_maps.cf).

    If it helps, my mysql_virtual_domains_maps.cf looks like this:


    MacMiniServer:~ Rimas$ cat /etc/postfix/mysql_virtual_alias_maps.cf
    user = mailsrvr
    password = ********
    hosts = 127.0.0.1
    dbname = postfix
    query = SELECT goto FROM alias WHERE address='%s' AND active = 1
    MacMiniServer:~ Rimas$

    I have tried changing user = mailsrvr to user = Rimas, and also hosts = 127.0.0.1 to hosts = localhost but to no avail. At this point I feel like I am kinda stuck and am hoping that I am just missing something really obvious.

    Thanks,

    Rimas

  • Richard
    16 Mar 2008

    Ok, sorry for the late reply but I was out of the country for work...

    Do you have a firewall enabled ? Can you tell me which version of OS X you are running ?

    Can you try using sockets ?

    
    user = mailsrvr
    password = ********
    hosts = unix:/tmp/mysql.sock
    dbname = postfix
    

    Make sure that your socket file is in the same place, you can use the command "mysql_config" to see where our socket file is.

  • Rimas
    30 May 2008

    Hi... OK, adding e-mail capability to the domain that I am hosting on my Mac Mini server is obviously not a high priority, so don't worry about the delay in responding. Just to close out this dangling thread, using sockets as suggested did in fact solve this problem when I finally got back to it the other day...

    If I may, I would like to suggest that you update your wonderful documentation to say that if you add "skip-networking" to your /etc/my.cnf as suggested in the instructions for "Securing your MySQL install", that you will need to use sockets in the mysql_virtual_xxxxxxx_maps.cf files when "Configuring Postfix for virtual domains using MySQL".

    Cheers,

    Rimas

  • Richard
    31 May 2008

    Thanks will do that.

Reply

You must log in to post.