DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(mysql.info) mysql-server-init

Info Catalog (mysql.info) c-embedded-server-func (mysql.info) c-embedded-server-func (mysql.info) 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', and so forth) 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 are active. See  option-files. For
 convenience, `groups' may be `NULL', in which case the `[server]' and
 `[embedded]' groups are 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) c-embedded-server-func (mysql.info) c-embedded-server-func (mysql.info) mysql-server-end
automatically generated byinfo2html