티스토리 툴바

BLOG main image
분류 전체보기 (31)
Solaris/Linux (12)
Oracle (2)
Python (5)
Php (1)
Linux C (2)
Mysql (3)
Network (2)
English (3)
작업일지 (0)
3,648 Visitors up to today!
Today 2 hit, Yesterday 4 hit
daisy rss
tistory 티스토리 가입하기!
2008/10/30 21:38

 

 

#include <stdlib.h>
#include <stdio.h>

#include "mysql.h"

int main(int argc, char *argv[]) {
        MYSQL *conn_ptr;
        conn_ptr = mysql_init(NULL);
        if(!conn_ptr) {
                fprintf(stderr, "mysql_init failed\n");
                return 1;
        }

        conn_ptr = mysql_real_connect(conn_ptr,"호스트명","계정ID","계정PW","데이터베이스명",0,NULL,0);

        if(conn_ptr) {
                printf("Connection success\n");
        }else{
                printf("Connection failed\n");
        }

        mysql_close(conn_ptr);
        return 0;
}


이렇게. 쳐넣고  testmysql.c 로 저장하자. 그리고

컴파일을 해보자.

gcc -I/usr/include/mysql testmysql.c -lmysqlclient -o testmysql
이제 실행하면 접속/실패 메시지를 볼수 있다.
Trackback Address :: http://digitalhermes.tistory.com/trackback/34 관련글 쓰기
Name
Password
Homepage
Secret
prev"" #1 #2 #3 #4 #5 ... #31 next