mysql各接口函数

MYSQL mysql;

先init才能connect

mysql_init(&mysql);

mysql_real_connect(MYSQL * mysql, char *host, char *user, char *password, unsigned int port, char *dbName, char *unixsocket, unsigned long clientflag);

/上面描述了五个参数的主要取值,MYSQL *为mysql_init函数返回的指针,host为null或              // localhost时链接的是本地的计算机,当mysql默认安装在unix(或类unix)系统中,root账户是没// 有密码的,因此用户名使用root,密码为null,当db为空的时候,函数链接到默认数据库,在进行  // mysql安装时会存在默认的test数据库,因此此处可以使用test数据库名称,port端口为0,使用    // unix连接方式,unix_socket为null时,表明不使用socket或管道机制,最后一个参数经常设置为0

Flag Name    Flag Description
      CLIENT_COMPRESS    Use compression protocol.
      CLIENT_FOUND_ROWS    Return the number of found (matched) rows, not the number of
 changed rows.
      CLIENT_IGNORE_SPACE    Allow spaces after function names. Makes all functions names 
reserved words.
      CLIENT_INTERACTIVE    Allow interactive_timeout seconds (instead of wait_timeout 
seconds) of inactivity before closing the connection. The client's session wait_timeout 
variable is set to the value of the session interactive_timeout variable.
      CLIENT_LOCAL_FILES    Enable LOAD DATA LOCAL handling.
      CLIENT_MULTI_STATEMENTS    Tell the server that the client may send multiple 
statements in a single string (separated by ‘;Â’). If this flag is not set, 
multiple-statement execution is disabled. Added in MySQL 4.1.
      CLIENT_MULTI_RESULTS    Tell the server that the client can handle multiple result 
sets from multiple-statement executions or stored procedures. This is automatically 
set if CLIENT_MULTI_STATEMENTS is set. Added in MySQL 4.1.
      CLIENT_NO_SCHEMA    Don't allow the db_name.tbl_name.col_name syntax. This is for 
ODBC. It causes the parser to generate an error if you use that syntax, which is useful
 for trapping bugs in some ODBC programs.
      CLIENT_ODBC    The client is an ODBC client. This changes mysqld to be more
 ODBC-friendly.
      CLIENT_SSL    Use SSL (encrypted protocol). This option should not be set by 
application programs; it is set internally in the client library. Instead, use 
mysql_ssl_set() before calling mysql_real_connect().

// 关闭链接

mysql_close(&mysql);

//选择数据库

mysql_select_db(&mysql, char * dbName);

 

你可能感兴趣的:(mysql各接口函数)