Name

mysql_library_init()

Synopsis

int mysql_library_init(int argc, char **argv, char **groups)

Use this function to initialize the MySQL library and any related libraries and systems before making any other MySQL function calls. It can be used with both the normal client library or the embedded server library. This function is used within a multithreaded environment. Otherwise, it’s not necessary and mysql_init() is sufficient. When finished, use mysql_library_end() to close the library. This function returns zero if successful, nonzero if not.

Here is an example:

...
static char *server_args[] = {
  "--datadir='/data'",
  "--key_buffer_size=32M"
};
static char *server_groups[] = {
  "embedded",
  "server",
  (char *)NULL
};
int main(int argc, char *argv[  ]) {
  if(mysql_library_init(sizeof(server_args) / sizeof(char *),
                        server_args, server_groups)) {
    fprintf(stderr, "Cannot initialize MySQL library \n");
    return 1;
  }
...
mysql_library_end();
...
}

Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.