mysql_real_connect 端口号说明

本文详细介绍了MySQL客户端API中的mysql_real_connect函数,包括其语法、参数含义及如何建立数据库连接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  mysql_real_connect语法:

 C++ Code 
1
2
3
4
5
6
7
8
 
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 flags);

  参数说明

  mysql - a mysql handle, which was previously allocated by mysql_init().
  host - can be either a host name or an IP address. Passing the NULL value or the string "localhost" to this parameter, the local host is assumed. When possible, pipes will be used instead of the TCP/IP protocol.
  user - the user name.
  passwd - If provided or NULL, the server will attempt to authenticate the user against those user records which have no password only. This allows one username to be used with different permissions (depending on if a password as provided or not).
  db - if provided will specify the default database to be used when performing queries.
  port - specifies the port number to attempt to connect to the server.  如果“port”不是0,其值将用作TCP/IP连接的端口号。port为0的话,使用mysql的默认tcp/ip端口3306.
  unix_socket - specifies the socket or named pipe that should be used.
  flags - the flags allows various connection options to be set:

  • CLIENT_FOUND_ROWS: Return the number of matched rows instead of number of changed rows.
  • CLIENT_NO_SCHEMA: Forbids the use of database.tablename.column syntax and forces the SQL parser to generate an error.
  • CLIENT_COMPRESS: Use compression protocol
  • CLIENT_IGNORE_SPACE: Allows spaces after function names. All function names will become reserved words.
  • CLIENT_LOCAL_FILES: Allows LOAD DATA LOCAL statements
  • CLIENT_MULTI_STATEMENTS: Allows the client to send multiple statements in one command. Statements will be divided by a semicolon.
  • CLIENT_MULTI_RESULTS: Indicates that the client is able to handle multiple result sets from stored procedures or multi statements. This option will be automatically set if CLIENT_MULTI_STATEMENTS is set.

转载于:https://www.cnblogs.com/MakeView660/p/7452318.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值