Linux中国  设为主页
 收藏本站
 
当前位置: > 首页 ->数据库应用 ->Mysql ->mysql中的mysql_real_connect连接参数设置
  相关分类: 
Access
DB2
Mysql
Oracle
PostgreSQL
SQL Server
Sybase
其他数据库
  站内搜索: 
热门文章排行
热门文章排行 Linux 安装 Mysql (04-22)
Heartbeat_2.0.3配置MySQL5.0.18集群(04-23)
Tomcat5配置MySQL JDBC数据库连接池(04-12)
Mysql日常备份和增量备份脚本(Linux)(04-23)
MySQL (C API)VC实例及代码下载 (04-23)
精采文章排行
精采文章排行 MySQL数据库中数据库移植中的乱码问(06-29)
Oracle是波音747还是MySQL丰田汽车呢(06-29)
意料外的MySQL运算符可获更多数据功(06-29)
轻松八句话 教会你完全搞定MySQL数据(06-29)
完全讲解PHP+MySQL的分页显示示例分(06-29)
  ·实战经验:PHP+MySQL数据库论坛简易通 ·新手入门:如何在MySQL数据库中定义外键 ·MySQL数据库中SELECT语句快速精细掌握 ·MySQL系统服务安装与卸载精彩问题汇总 ·完全优化MySQL数据库性能的八大巧方法 ·MySQL服务器内部安全数据目录如何访问 ·讲解MySQL服务器安装之后如何调节性能 ·如何利用Debugview方式来调试MySQL UDF ·MySQL ODBC进行MySQL和SQL Server转换

mysql中的mysql_real_connect连接参数设置

作者:Webmaster   来源:Linuxdby.com   点击:   日期:2007-06-03 [收藏] [投稿]

  IE是否经常中毒?推荐您

在前一篇文章中,讲述了如何进行mysql源程序代码的编译链接,但是没有讲述运行情况,在按照上一篇文章代码下进行编译运行后,发现无法链接数据库文件,显然是在mysql_real_connect()函数中出现了问题。在mysql的英文手册中找到关于mysql_real_connect()的如下描述:
     
//函数原型描述 MYSQL *mysql_real_connect(MYSQL *mysql, const char *host, const char *user,
const char *passwd, const char *db, unsigned int port, const char *unix_socket,
unsigned long client_flag)

Description

mysql_real_connect() attempts to establish a connection to a MySQL database engine
running on host. mysql_real_connect() must complete successfully before you can
execute any other API functions that require a valid MYSQL connection handle structure.

The parameters are specified as follows:

    *

      The first parameter should be the address of an existing MYSQL structure. Before
 calling mysql_real_connect() you must call mysql_init() to initialize the MYSQL
structure. You can change a lot of connect options with the mysql_options() call.
See Section 17.2.3.47, “mysql_options()”.
    *

      The value of host may be either a hostname or an IP address. If host is NULL or the
string "localhost", a connection to the local host is assumed. If the OS supports sockets
(Unix) or named pipes (Windows), they are used instead of TCP/IP to connect to the server.
    *

      The user parameter contains the user's MySQL login ID. If user is NULL or the empty
string "", the current user is assumed. Under Unix, this is the current login name. Under
 Windows ODBC, the current username must be specified explicitly. See Section 18.1.9.2,
 Â“Configuring a MyODBC DSN on Windows”.
    *

      The passwd parameter contains the password for user. If passwd is NULL, only entries
 in the user table for the user that have a blank (empty) password field are checked for a
match. This allows the database administrator to set up the MySQL privilege system in
such a way that users get different privileges depending on whether they have specified
a password.

      Note: Do not attempt to encrypt the password before calling mysql_real_connect();
 password encryption is handled automatically by the client API.
    *

      db is the database name. If db is not NULL, the connection sets the default database
to this value.
    *

      If port is not 0, the value is used as the port number for the TCP/IP connection. Note
that the host parameter determines the type of the connection.
    *

      If unix_socket is not NULL, the string specifies the socket or named pipe that should
 be used. Note that the host parameter determines the type of the connection.
    *

      The value of client_flag is usually 0, but can be set to a combination of the following
flags to enable certain features:

//上面描述了五个参数的主要取值,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.

 如果您对本文有任何疑问或者建议,请到讨论区发表您的意见: >> 论坛入口 <<

上一页12 3 下一页

上一篇:mysql存储过程及c#调用标准版   下一篇:Mysql分页查询通用存储过程
文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论

   相关文章:
·帮助你如何迅速优化你MySQL数据库性能

   文章评论:(1条)
  
 请留名: 匿名评论   点击查看所有评论 论坛讨论
 

 声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。