Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

25.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 Section 4.3.2, “Using 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.


 
 
  Published under the terms of the GNU General Public License Design by Interspire