(mysql.info.gz) mysql_server_init
Info Catalog
(mysql.info.gz) C Embedded Server func
(mysql.info.gz) C Embedded Server func
(mysql.info.gz) mysql_server_end
22.2.12.1 `mysql_server_init()'
...............................
`int mysql_server_init(int argc, char **argv, char **groups)'
Description
...........
This function *must* be called once in the program using the embedded
server before calling any other MySQL function. It starts the server
and initializes any subsystems (`mysys', `InnoDB', etc.) that the
server uses. If this function is not called, the next call to
`mysql_init()' executes `mysql_server_init()'. If you are using the
DBUG package that comes with MySQL, you should call this after you have
called `my_init()'.
The `argc' and `argv' arguments are analogous to the arguments to
`main()'. The first element of `argv' is ignored (it typically
contains the program name). For convenience, `argc' may be `0' (zero)
if there are no command-line arguments for the server.
`mysql_server_init()' makes a copy of the arguments so it's safe to
destroy `argv' or `groups' after the call.
If you want to connect to an external server without starting the
embedded server, you have to specify a negative value for `argc'.
The `NULL'-terminated list of strings in `groups' selects which groups
in the option files will be active. Option files. For
convenience, `groups' may be `NULL', in which case the `[server]' and
`[embedded]' groups will be active.
Example
.......
#include <mysql.h>
#include <stdlib.h>
static char *server_args[] = {
"this_program", /* this string is not used */
"--datadir=.",
"--key_buffer_size=32M"
};
static char *server_groups[] = {
"embedded",
"server",
"this_program_SERVER",
(char *)NULL
};
int main(void) {
if (mysql_server_init(sizeof(server_args) / sizeof(char *),
server_args, server_groups))
exit(1);
/* Use any MySQL API functions here */
mysql_server_end();
return EXIT_SUCCESS;
}
Return Values
.............
0 if okay, 1 if an error occurred.
Info Catalog
(mysql.info.gz) C Embedded Server func
(mysql.info.gz) C Embedded Server func
(mysql.info.gz) mysql_server_end
automatically generated byinfo2html