Cira Account wrote:
I apologize if the listings below are badly
formatted.  I am posting this from a webmail client
and it has very short line lengths.

I am using MySQL 4.0.17 on QNX 6.2.0. I can connect
by typing "mysql -u root" from the command line. However, I get:


    Database connect failed
    Can't connect to local MySQL server through
socket '' (261) (2002)

when I run this program:

#include <stdio.h>
#include <mysql/mysql.h>

int main(int argc, char *argv[])
{
    MYSQL       mysql;

    if (!mysql_init(&mysql))
    {
        fprintf(stderr, "mysql_init failed\n");
    }
    else if (!mysql_real_connect(&mysql,
"localhost", "root", "", "qsbr", 0, "",
        0) )
    {
        fprintf(stderr, "Database connect failed\n");
        fprintf(stderr, "%s (%d)\n", mysql_error(&mysql),
mysql_errno(&mysql));
    }
#if 0
    else
    {
        int error = mysql_query(&mysql,
            "select * from packet where date_add(timestamp, "
            "interval 15 second) < now() order by priority
desc, timestamp;");
        fprintf(stdout, "error = %d\n", error);
    }
#endif
    return(0);
}

Error 261 on QNX means "connection refused". Try specifying the socket path explicitly when calling mysql_real_connect() after you have verified that the server is actually running.


--
Sasha Pachev
Create online surveys at http://www.surveyz.com/

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to