database,sql,query,table,mysql

The error message is :
    Connection failed
    Connection error 2002: Can't connect to local MySQL server through socket 
'/tmp/mysql.sock' (111)
 
my program is :
#include <stdlib.h> 
#include <stdio.h> 
#include "mysql.h" 
int main(int argc, char *argv[]) { 
MYSQL my_connection; 
int res; 
mysql_init(&my_connection); 
if (mysql_real_connect(&my_connection, "localhost","monty", "something", "nvod", 0, 
NULL, 0)) { 
    printf("Connection success\n"); 
    res = mysql_query(&my_connection, "insert into task_log(task_id,content) 
values(111,'c programing')"); 
    if (!res) { 
    printf("Inserted %lu rows\n", (unsigned long)mysql_affected_rows(&my_connection)); 
    } else { 
    fprintf(stderr, "Insert error %d: 
s\n",mysql_errno(&my_connection),mysql_error(&my_connection)); 
    } 
    mysql_close(&my_connection); 
} else { 
    fprintf(stderr, "Connection failed\n"); 
    if (mysql_errno(&my_connection)) { 
    fprintf(stderr, "Connection error %d: 
%s\n",mysql_errno(&my_connection),mysql_error(&my_connection)); 
    } 
   } 
    return EXIT_SUCCESS; 
} 
 
my machine is :
red hat 6.0
mysql 3.23.32
I can use "mysql -u monty -psomething" to  login .

under dirctory of /var/lib/mysql/ 
        srwxrwxrwx   1 mysql    mysql           0 Jun 23 19:51 mysql.sock
under dirctory of /tmp 
        -rwxrwxrwx   1 wz       wz              0 Jun 25 09:39 mysql.sock
Are these message is correct?

how to fix it? Have somebody know?
Thanks.
            eagle
            [EMAIL PROTECTED]


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to