[C 04.03] 02. mysql접속하기
2011. 4. 3. 22:04ㆍC
반응형
#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; } |
반응형
'C' 카테고리의 다른 글
[C 09.09] 01. C언어 기초 통틀어 (0) | 2010.09.09 |
---|