Problem with SQLGrey and MySQL

started at 04 Apr 2011 by Lindhardsen
  • Lindhardsen
    04 Apr 2011

    Hi!

    I have a problem that has been keeping me puzzled since I installed my OSX "Server" in October:

    When I restart my server, postfix cannot connect to Dovecot. This it turns out, is related to that postgrey cannot ponnect to the database.
    For some reason, sqlgrey is trying to connect to the socket (I assume) /tmp/mysql.sock!

    The workaround for this is simple, just create a link from the socket file /private/var/mysql/mysql.sock to /tmp/mysql.sock using:
    "ln /private/var/mysql/mysql.sock /tmp/mysql.sock".
    The disadvantage of this, is that /tmp is emptied on every restart of the server, so I have to manually run this command after each restart.

    But WHY is this happening? Looking in my sqlgrey.conf, I have the following connection settings:
    db_type = mysql
    db_name = sqlgrey
    # Note: the following are not used with SQLite
    db_host = localhost
    db_port = default

    Which is the same as any other component that uses MySQL on the system, and all other works fine!
    I have tried to change the location of the mysql.sock file, but that basically causes all other components to fail :-(

    Is there a hidden setting in perl (which sqlgrey is built upon), which points to an alternative mysql location?

    Alternatively how can I prevent OSX from deleting the /tmp/mysql.sock link on shutdown?

    What I see in my system.log file is this:
    Apr 4 10:38:52 Minin com.diymacserver.sqlgrey[357]: dbaccess: can't connect to DB: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
    Apr 4 10:38:52 Minin com.diymacserver.sqlgrey[357]: dbaccess: error: couldn't get now() from DB: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

    Best regards,
    Jan

  • Richard
    04 Apr 2011

    Jan, which version of MySQl have you got installed and are you running a real OSX server or our DIYMacServer?

  • Richard
    04 Apr 2011

    Also, I forgot, do you have a MYSQL config file in /etc/ called my.cnf

  • Richard
    04 Apr 2011

    After some googling I found that Perl uses the MYSQL config file to determine the connection or socket settings in the config file.

    Otherwise we need to change the code to make a database connection look like:
    DBI->connect("DBI:mysql:host=localhost:mysql_socket=/tmp/mysql.sock;database=business"...

  • Lindhardsen
    04 Apr 2011

    Hi Richard, thanks for your responses, your help is highly appreciated!

    I'm running an DIY server, the only thing that is not according to your guides, is the MySQL, which I downloaded and installed of the MySQL website back in October, just before I found your excellent website.
    The version is Server version: 5.1.51 MySQL Community Server
    the my.cfn is located in /private/etc/my.cnf and the content is:

    [client]
    socket = /var/mysql/mysql.sock
    
    [mysqld]
    socket = /var/mysql/mysql.sock

    And if I understand you correct, this is the setting that SQLGrey should pick up, just as the rest of the components does correctly. Right?
    If I'm to change the connection setting, where should I do that? In my amateur eyes, this all seems just about right... Maybe I'm looking in the wrong place?

  • Richard
    05 Apr 2011

    Jan did you enable the skip-networking option in MySQL so it can only use the socket for connectivity?

  • Lindhardsen
    05 Apr 2011

    No, Skip-networking is not enabled.
    On the other hand, neither is "port", could that be a problem? I guess not, at least not related to this...

  • Richard
    07 Apr 2011

    I'll see if I can reproduce your problem to be able to determine a solution.

  • Lindhardsen
    07 Apr 2011

    That's really great service. I hope you will be able to find a clue somewhere, as I have ran my forehead against the wall one to many time now!

Reply

You must log in to post.