mysql_real_connect — Establish a connection to database server
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);Establishes a connection to a database server.
mysqlA mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().
hostCan 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 protoco
userThe user name
passwdIf 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).
dbIf provided will specify the default database to be used when performing queries.
portSpecifies the port number to attempt to connect to the server.
unix_socketSpecifies the socket or named pipe that should be used.
flagsThe flags allows to set various connection options:
CLIENT_FOUND_ROWSReturn the number of matched rows instead of number of changed rows.
CLIENT_NO_SCHEMAForbids the use of database.tablename.column syntax and forces the SQL parser to generate an error.
CLIENT_COMPRESSUse compression protocol
CLIENT_IGNORE_SPACEThis option makes all function names reserved words.
CLIENT_LOCAL_FILESUse compression protocol
CLIENT_MULTI_STATEMENTSAllows the client to send multiple statements in one command. Statements will be divided by a semicolon.
CLIENT_MULTI_RESULTSIndicates that the client is able to handle multiple result sets from stored procedures or multi statements. This option will be automatically set if CLIENT_MULTIO_STATEMENTS is set.