| mysql_real_connect(3) | MariaDB Connector/C | mysql_real_connect(3) |
mysql_real_connect - establishes a connection to a MariaDB 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.
| Flag | Description |
| 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. |
| CLIENT_REMEMBER_OPTIONS | Remembers options passed to mysql_optionsv(3) if a connect attempt failed. If MYSQL_OPTIONS_RECONNECT option was set to true, options will be saved and used for reconnection. |
returns a connection handle (same as passed for 1st parameter) or NULL on error. On error, please check mysql_errno(3) and mysql_error(3) functions for more information.
Examples for failover host string:
host=[::1]:3306,192.168.0.1:3306,test.example.com
host=127.0.0.1:3306,
| Version 3.4 |