1mysql_real_connect(3)         MariaDB Connector/C        mysql_real_connect(3)
2
3
4
5   Name
6       mysql_real_connect  -  establishes  a  connection to a MariaDB database
7       server
8
9   Synopsis
10              MYSQL * mysql_real_connect(MYSQL *mysql,
11                                         const char *host,
12                                         const char *user,
13                                         const char *passwd,
14                                         const char *db,
15                                         unsigned int port,
16                                         const char *unix_socket,
17                                         unsigned long flags);
18
19   Description
20       Establishes a connection to a database server.
21
22   Parameter
23       • mysql  -  a  mysql  handle,  which  was   previously   allocated   by
24         mysql_init(3)
25
26       • host  - can be either a host name or an IP address.  Passing the NULL
27         value or the string “localhost” to this parameter, the local host  is
28         assumed.   When  possible,  pipes  will be used instead of the TCP/IP
29         protocol.
30
31       • user - the user name.
32
33       • passwd - If provided or NULL, the server will attempt to authenticate
34         the  user  against  those  user  records which have no password only.
35         This allows one username to be used with different  permissions  (de‐
36         pending on if a password as provided or not).
37
38       • db  -  if  provided will specify the default database to be used when
39         performing queries.
40
41       • port - specifies the port number to attempt to connect to the server.
42
43       • unix_socket - specifies the socket or named pipe that should be used.
44
45       • flags - the flags allows various connection options to be set
46       Flag                                  Description
47       ──────────────────────────────────────────────────────────────────────────
48       CLIENT_FOUND_ROWS                     Return the number of  matched  rows
49                                             instead of number of changed rows.
50       CLIENT_NO_SCHEMA                      Forbids  the use of database.table‐
51                                             name.column syntax and  forces  the
52                                             SQL parser to generate an error.
53       CLIENT_COMPRESS                       Use compression protocol
54       CLIENT_IGNORE_SPACE                   Allows spaces after function names.
55                                             All function names will become  re‐
56                                             served words.
57       CLIENT_LOCAL_FILES                    Allows LOAD DATA LOCAL statements
58       CLIENT_MULTI_STATEMENTS               Allows  the client to send multiple
59                                             statements in one command.   State‐
60                                             ments  will  be  divided by a semi‐
61                                             colon.
62
63
64
65
66
67       CLIENT_MULTI_RESULTS                  Indicates that the client  is  able
68                                             to handle multiple result sets from
69                                             stored procedures or  multi  state‐
70                                             ments.   This  option will be auto‐
71                                             matically   set   if    CLIENT_MUL‐
72                                             TI_STATEMENTS is set.
73       CLIENT_REMEMBER_OPTIONS               Rembers options passed to mysql_op‐
74                                             tionsv(3)  if  a  connect   attempt
75                                             failed.  If MYSQL_OPTIONS_RECONNECT
76                                             option was  set  to  true,  options
77                                             will  be  saved and used for recon‐
78                                             nection.
79
80   Return value
81       returns a connection handle (same as passed for 1st parameter) or  NULL
82       on  error.   On  error,  please check mysql_errno(3) and mysql_error(3)
83       functions for more information.
84
85   Notes
86       • The password doesn’t need to be encrypted before executing  mysql_re‐
87         al_connect().  This will be handled in the client server protocol.
88
89       • The  connection handle can’t be reused for establishing a new connec‐
90         tion.  It must be closed and reinitialized before.
91
92       • mysql_real_connect() must complete successfully before you  can  exe‐
93         cute any other API functions beside mysql_optionsv(3).
94
95   See also
96mysql_init(3)
97
98mysql_close(3)
99
100mariadb_reconnect(3)
101
102mysql_error(3)
103
104mysql_errno(3)
105
106
107
108Version 3.2.2                                            mysql_real_connect(3)
Impressum