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是否经常中毒?推荐您


      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().

For some parameters, it is possible to have the value taken from an option file rather
than from an explicit value in the mysql_real_connect() call. To do this, call
mysql_options() with the MYSQL_READ_DEFAULT_FILE or MYSQL_READ_DEFAULT_GROUP option
before calling mysql_real_connect(). Then, in the mysql_real_connect() call, specify
the “no-value” value for each parameter to be read from an option file:

    *

      For host, specify a value of NULL or the empty string ("").
    *

      For user, specify a value of NULL or the empty string.
    *

      For passwd, specify a value of NULL. (For the password, a value of the empty string in
 the mysql_real_connect() call cannot be overridden in an option file, because the empty
string indicates explicitly that the MySQL account must have an empty password.)
    *

      For db, specify a value of NULL or the empty string.
    *

      For port, specify a value of 0.
    *

      For unix_socket, specify a value of NULL.

If no value is found in an option file for a parameter, its default value is used as
indicated in the descriptions given earlier in this section.

Return Values

A MYSQL* connection handle if the connection was successful, NULL if the connection
was unsuccessful. For a successful connection, the return value is the same as the value
of the first parameter.
// 返回值:当连接成功时,返回MYSQL连接句柄,失败,返回NULL。当成功时,返回值与第一个参数值是// 相同的。

Errors

    *

      CR_CONN_HOST_ERROR

      Failed to connect to the MySQL server.
    *

      CR_CONNECTION_ERROR

      Failed to connect to the local MySQL server.
    *

      CR_IPSOCK_ERROR

      Failed to create an IP socket.
    *

      CR_OUT_OF_MEMORY

      Out of memory.
    *

      CR_SOCKET_CREATE_ERROR

      Failed to create a Unix socket.
    *

      CR_UNKNOWN_HOST

      Failed to find the IP address for the hostname.
    *

      CR_VERSION_ERROR

      A protocol mismatch resulted from attempting to connect to a server with a client
library that uses a different protocol version. This can happen if you use a very old
client library to connect to a new server that wasn't started with the --old-protocol
option.
    *

      CR_NAMEDPIPEOPEN_ERROR

      Failed to create a named pipe on Windows.
    *

      CR_NAMEDPIPEWAIT_ERROR

      Failed to wait for a named pipe on Windows.
    *

      CR_NAMEDPIPESETSTATE_ERROR

      Failed to get a pipe handler on Windows.
    *

      CR_SERVER_LOST

      If connect_timeout > 0 and it took longer than connect_timeout seconds to connect to
the server or if the server died while executing the init-command.


    因此mysql_real_connect()函数调用为:
       mysql_real_connect(mysql,"localhost","root",NULL,"test",0,NULL,0);
判断是否出错,出错调用mysql_error()函数显示出错信息,或使用mysql_errno()函数获取出错代号。

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

上一页 1 23 下一页

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

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

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

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