[Dovecot] Problem with MySQL

Emmeran Sollner emmeran at gmx.net
Fri Sep 15 04:29:42 EEST 2006


Hi there,
I tried to setup a passwddb with mysql, but it wont connect to my
database, even if I patch the driver-mysql.c

Here a test program I wrote to check the connection:
int main()
{
    MYSQL mysql;
    mysql_init(&mysql);
    if (mysql_real_connect(&mysql, NULL, "root", "asd2sdf3", "ccc", 0,
"/var/lib/mysql/mysql.sock", 0) == NULL)
        printf("connection failed: %s\n", mysql_error(&mysql));
    else
        printf("nos problemos\n");
    return 0;
}

This program executed says "nos problemos" --> connection works
The same data in dovecot.conf brings up this:
Sep 15 03:08:38 suse10064lamp dovecot: auth-worker(default): ok...
connecting to mysql: host='(null)', user='root', pass='asd2sdf3',
db='ccc', port='0', sock='/var/lib/mysql/mysql.sock'
Sep 15 03:08:38 suse10064lamp dovecot: auth-worker(default): mysql:
Connect failed to /var/lib/mysql/mysql.sock (ccc): Access denied for
user 'root'@'localhost' (using password: YES) - waiting for 1 seconds
before retry

I added a i_info() in front of the mysql_real_connect command to test if
the data from the config file is transmitted correctly (first line
above) --> it is

So i tried to connect to mysql with the line from my test-program. this
is the patched code:
        i_info("ok... connecting to mysql: host='%s', user='%s',
pass='%s', db='%s', port='%i', sock='%s'", host, db->user, db->password,
db->dbname, db->port, unix_socket);
/*      failed = mysql_real_connect(conn->mysql, host, db->user,
db->password,
                                    db->dbname, db->port, unix_socket,
                                    db->client_flags) == NULL;
*/      failed = mysql_real_connect(conn->mysql, NULL, "root",
"asd2sdf3", "ccc", 0, "/var/lib/mysql/mysql.sock", 0) == NULL;


And it still says:
Sep 15 03:08:38 suse10064lamp dovecot: auth-worker(default): ok...
connecting to mysql: host='(null)', user='root', pass='asd2sdf3',
db='ccc', port='0', sock='/var/lib/mysql/mysql.sock'
Sep 15 03:08:38 suse10064lamp dovecot: auth-worker(default): mysql:
Connect failed to /var/lib/mysql/mysql.sock (ccc): Access denied for
user 'root'@'localhost' (using password: YES) - waiting for 1 seconds
before retry


Any ideas?
Thx in advance,
Emmeran


More information about the dovecot mailing list