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);

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值